/**
  * @param string $expectedTranslationDomain
  * @param array $options
  * @param string|null $parentTranslationDomain
  * @param array $expectedChoices
  * @param array $inputChoices
  *
  * @dataProvider finishViewDataProvider
  */
 public function testFinishView($expectedTranslationDomain, $options, $parentTranslationDomain = null, $expectedChoices = array(), $inputChoices = array())
 {
     // expectations for translator
     if ($expectedChoices) {
         $prefix = self::TRANSLATION_PREFIX;
         $this->translator->expects($this->exactly(count($expectedChoices)))->method('trans')->with($this->isType('string'), array(), $expectedTranslationDomain)->will($this->returnCallback(function ($id) use($prefix) {
             return $prefix . $id;
         }));
     } else {
         $this->translator->expects($this->never())->method('trans');
     }
     /** @var FormInterface $form */
     $form = $this->getMockBuilder('Symfony\\Component\\Form\\Test\\FormInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $filterFormView = $this->getFilterFormView($parentTranslationDomain, $inputChoices);
     $this->instance->finishView($filterFormView, $form, $options);
     // get list of actual translated choices
     /** @var FormView $valueFormView */
     $valueFormView = $filterFormView->children['value'];
     $choiceViews = $valueFormView->vars['choices'];
     $actualChoices = array();
     /** @var ChoiceView $choiceView */
     foreach ($choiceViews as $choiceView) {
         $actualChoices[$choiceView->value] = $choiceView->label;
     }
     $this->assertEquals($expectedChoices, $actualChoices);
 }
 /**
  * {@inheritDoc}
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     parent::finishView($view, $form, $options);
     if (isset($options['populate_default'])) {
         $view->vars['populate_default'] = $options['populate_default'];
     }
 }
 /**
  * {@inheritDoc}
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     parent::finishView($view, $form, $options);
     if (isset($options['populate_default'])) {
         $view->vars['populate_default'] = $options['populate_default'];
         $view->vars['default_value'] = $options['default_value'];
     }
     if (!empty($options['null_value'])) {
         $view->vars['null_value'] = $options['null_value'];
     }
     if (!empty($options['class'])) {
         $view->vars['class'] = $options['class'];
     }
 }
 /**
  * {@inheritDoc}
  */
 protected function translateChoices(FormView $view, FormView $valueFormView, array $options)
 {
     if (!isset($options['is_translated_choices']) || !$options['is_translated_choices']) {
         parent::translateChoices($view, $valueFormView, $options);
     }
 }
 /**
  * @param TranslatorInterface $translator
  */
 public function __construct(TranslatorInterface $translator)
 {
     parent::__construct($translator);
 }
Exemple #6
0
 /**
  * @param TranslatorInterface $translator
  * @param ManagerRegistry     $doctrine
  */
 public function __construct(TranslatorInterface $translator, ManagerRegistry $doctrine)
 {
     parent::__construct($translator);
     $this->doctrine = $doctrine;
 }
Exemple #7
0
 /**
  * @param TranslatorInterface $translator
  * @param EnumValueProvider $valueProvider
  */
 public function __construct(TranslatorInterface $translator, EnumValueProvider $valueProvider)
 {
     parent::__construct($translator);
     $this->valueProvider = $valueProvider;
 }