mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
fix deprecations in closingMotive
This commit is contained in:
parent
7227b89d4f
commit
3bf7838731
@ -7,6 +7,8 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||
|
||||
/**
|
||||
* A type to add a closing motive
|
||||
@ -16,16 +18,18 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
class ClosingMotiveType extends AbstractType
|
||||
{
|
||||
|
||||
private $locale;
|
||||
|
||||
public function __construct(Request $request = NULL)
|
||||
/**
|
||||
*
|
||||
* @var TranslatableStringHelper
|
||||
*/
|
||||
protected $translatableStringHelper;
|
||||
|
||||
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
if ($request !== NULL) {
|
||||
$this->locale = $request->getLocale();
|
||||
}
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'closing_motive';
|
||||
}
|
||||
@ -37,17 +41,14 @@ class ClosingMotiveType extends AbstractType
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
if ($this->locale === NULL) {
|
||||
throw new \LogicException('the locale should be defined and is extracted '
|
||||
. 'from the \'request\' service. Maybe was this service '
|
||||
. 'unaccessible ?');
|
||||
}
|
||||
|
||||
$resolver->setDefaults(array(
|
||||
'class' => 'ChillPersonBundle:AccompanyingPeriod\ClosingMotive',
|
||||
'class' => ClosingMotive::class,
|
||||
'empty_data' => null,
|
||||
'placeholder' => 'Choose a motive',
|
||||
'choice_label' => 'name['.$this->locale.']'
|
||||
'choice_label' => function(ClosingMotive $cm) {
|
||||
return $this->translatableStringHelper
|
||||
->localize($cm->getName());
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -11,9 +11,8 @@ services:
|
||||
|
||||
chill.person.accompanying_period_closing_motive:
|
||||
class: Chill\PersonBundle\Form\Type\ClosingMotiveType
|
||||
scope: request
|
||||
arguments:
|
||||
- "@request"
|
||||
- "@chill.main.helper.translatable_string"
|
||||
tags:
|
||||
- { name: form.type, alias: closing_motive }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user