Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     parent::setDefaultOptions($resolver);
     $resolver->setDefaults(['empty_value' => null, 'empty_data' => null]);
     $resolver->setNormalizers(['empty_value' => function (Options $options, $value) {
         return !$options['expanded'] && !$options['multiple'] ? 'oro.form.choose_value' : $value;
     }]);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     parent::setDefaultOptions($resolver);
     $defaultConfigs = ['allowClear' => true, 'placeholder' => 'oro.form.choose_value'];
     $resolver->setDefaults(['empty_value' => null, 'empty_data' => null, 'configs' => $defaultConfigs]);
     $resolver->setNormalizers(['empty_value' => function (Options $options, $value) {
         return !$options['expanded'] && !$options['multiple'] ? '' : $value;
     }, 'configs' => function (Options $options, $value) use(&$defaultConfigs) {
         return array_merge($defaultConfigs, $value);
     }]);
 }
Пример #3
0
 protected function doTestSetDefaultOptions(AbstractEnumType $type, OptionsResolver $resolver, $enumCode, $multiple = false, $expanded = false, array $options = [])
 {
     $enumValueClassName = ExtendHelper::buildEnumValueClassName($enumCode);
     // AbstractEnumType require class to be instance of AbstractEnumValue
     // This may be achieved with Stub. Stub namespace does not reflect Stub path. So we have to load it manually
     $fileName = ExtendHelper::getShortClassName($enumValueClassName) . '.php';
     require_once realpath(__DIR__ . DIRECTORY_SEPARATOR . 'Stub' . DIRECTORY_SEPARATOR . $fileName);
     $enumConfig = new Config(new EntityConfigId('enum', $enumValueClassName));
     $enumConfig->set('multiple', $multiple);
     $enumConfigProvider = $this->getConfigProviderMock();
     $this->configManager->expects($this->once())->method('getProvider')->with('enum')->will($this->returnValue($enumConfigProvider));
     $enumConfigProvider->expects($this->once())->method('getConfig')->with($enumValueClassName)->will($this->returnValue($enumConfig));
     $type->setDefaultOptions($resolver);
     $resolvedOptions = $resolver->resolve(array_merge($options, ['enum_code' => $enumCode, 'expanded' => $expanded]));
     $this->assertEquals($multiple, $resolvedOptions['multiple']);
     $this->assertEquals($expanded, $resolvedOptions['expanded']);
     $this->assertEquals($enumCode, $resolvedOptions['enum_code']);
     $this->assertEquals($enumValueClassName, $resolvedOptions['class']);
     $this->assertEquals('name', $resolvedOptions['property']);
     $this->assertNotNull($resolvedOptions['query_builder']);
     unset($resolvedOptions['multiple'], $resolvedOptions['expanded'], $resolvedOptions['enum_code'], $resolvedOptions['class'], $resolvedOptions['property'], $resolvedOptions['query_builder']);
     return $resolvedOptions;
 }