コード例 #1
0
 public function testOptionSortSortsByNumberForInvalidInput()
 {
     $option = $this->generateOption();
     $actual = OptionOrder::sort($option->getValues(), 'not-a-real-one');
     $expected = array('Beta', 'Alpha', 'Theta', 'Gamma', 'Zappa');
     $this->assertOrder($expected, $actual, 'Default is not sorting by numbers.');
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $choices = $this->option->getValues();
     if (!$choices->first()) {
         throw new MissingOptionsException(sprintf('The option "%s" must have values assigned before it may be used in a form.', $this->option->getName()));
     }
     $class = get_class($choices->first());
     // Remove locked values from choice list.
     $choices = $choices->filter(function ($choice) {
         return !$choice->isLocked();
     });
     // Sort choice list.
     $choices = OptionOrder::sort($choices, $this->sortBy);
     $resolver->setDefaults(array('class' => $class, 'choices' => $choices, 'empty_value' => 'dag.option.form.choose'));
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('choices' => OptionOrder::getChoices(), 'preferred_choices' => array(OptionOrder::DEFAULT_ORDER)));
 }