mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
user: correct dependency injection for form for locationType and userCurrentLocation
This commit is contained in:
parent
11b82f7468
commit
be92ac4a08
@ -15,15 +15,15 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
final class LocationFormType extends AbstractType
|
||||
{
|
||||
|
||||
// private TranslatableStringHelper $translatableStringHelper;
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
// /**
|
||||
// * @param TranslatableStringHelper $translatableStringHelper
|
||||
// */
|
||||
// public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||
// {
|
||||
// $this->translatableStringHelper = $translatableStringHelper;
|
||||
// }
|
||||
/**
|
||||
* @param TranslatableStringHelper $translatableStringHelper
|
||||
*/
|
||||
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
@ -38,8 +38,7 @@ final class LocationFormType extends AbstractType
|
||||
];
|
||||
},
|
||||
'choice_label' => function (EntityLocationType $entity) {
|
||||
//return $this->translatableStringHelper->localize($entity->getTitle()); //TODO not working. Cannot pass smthg in the constructor
|
||||
return $entity->getTitle()['fr'];
|
||||
return $this->translatableStringHelper->localize($entity->getTitle());
|
||||
},
|
||||
])
|
||||
->add('name', TextType::class)
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace Chill\MainBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Entity\Location;
|
||||
// use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@ -12,15 +12,15 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
class UserCurrentLocationType extends AbstractType
|
||||
{
|
||||
|
||||
// private TranslatableStringHelper $translatableStringHelper;
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
// /**
|
||||
// * @param TranslatableStringHelper $translatableStringHelper
|
||||
// */
|
||||
// public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||
// {
|
||||
// $this->translatableStringHelper = $translatableStringHelper;
|
||||
// }
|
||||
/**
|
||||
* @param TranslatableStringHelper $translatableStringHelper
|
||||
*/
|
||||
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
@ -29,9 +29,8 @@ class UserCurrentLocationType extends AbstractType
|
||||
'class' => Location::class,
|
||||
'choice_label' => function (Location $entity) {
|
||||
return $entity->getName() ?
|
||||
$entity->getLocationType()->getTitle()['fr'] . ' ' . $entity->getName() :
|
||||
//$this->translatableStringHelper->localize($entity->getLocationType()->getTitle()); //TODO does not work
|
||||
$entity->getLocationType()->getTitle()['fr'];
|
||||
$this->translatableStringHelper->localize($entity->getLocationType()->getTitle()) . ' ' . $entity->getName() :
|
||||
$this->translatableStringHelper->localize($entity->getLocationType()->getTitle());
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
@ -140,10 +140,10 @@ services:
|
||||
autoconfigure: true
|
||||
autowire: true
|
||||
|
||||
Chill\MainBundle\Form\Type\LocationFormType:
|
||||
Chill\MainBundle\Form\LocationFormType:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
|
||||
Chill\MainBundle\Form\Type\UserCurrentLocationType:
|
||||
Chill\MainBundle\Form\UserCurrentLocationType:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
autoconfigure: true
|
||||
|
@ -206,8 +206,7 @@ Location list: Liste des localisations
|
||||
Location type: Type de localisation
|
||||
Phonenumber1: Numéro de téléphone
|
||||
Phonenumber2: Autre numéro de téléphone
|
||||
Configure location: Configuration des localisations
|
||||
Configure location type: Configuration des types de localisations
|
||||
Configure location and location type: Configuration des localisations
|
||||
|
||||
# circles / scopes
|
||||
Choose the circle: Choisir le cercle
|
||||
|
Loading…
x
Reference in New Issue
Block a user