mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Using TranslatableStringHelper inside CustomFieldChoice, CustomFieldText & CustomFieldTitle
This commit is contained in:
@@ -1,6 +1,23 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Chill\CustomFieldsBundle\CustomFields;
|
||||
|
||||
@@ -9,11 +26,11 @@ use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Bundle\TwigBundle\TwigEngine;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @author Marc Ducobu <marc@champs-libres.coop>
|
||||
*/
|
||||
class CustomFieldText implements CustomFieldInterface
|
||||
{
|
||||
@@ -26,11 +43,18 @@ class CustomFieldText implements CustomFieldInterface
|
||||
*/
|
||||
private $templating;
|
||||
|
||||
/**
|
||||
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
|
||||
*/
|
||||
private $translatableStringHelper;
|
||||
|
||||
|
||||
public function __construct(RequestStack $requestStack, TwigEngine $templating)
|
||||
public function __construct(RequestStack $requestStack, TwigEngine $templating,
|
||||
TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
$this->requestStack = $requestStack;
|
||||
$this->templating = $templating;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
const MAX_LENGTH = 'maxLength';
|
||||
@@ -50,7 +74,7 @@ class CustomFieldText implements CustomFieldInterface
|
||||
: 'textarea';
|
||||
|
||||
$builder->add($customField->getSlug(), $type, array(
|
||||
'label' => $customField->getName()[$this->requestStack->getCurrentRequest()->getLocale()],
|
||||
'label' => $this->translatableStringHelper->localize($customField->getName()),
|
||||
'required' => false
|
||||
));
|
||||
}
|
||||
|
Reference in New Issue
Block a user