Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $defaultFieldOptions = ['multiple' => true];
     $resolver->setDefaults(['enum_code' => null, 'class' => null, 'field_options' => $defaultFieldOptions, 'operator_choices' => [self::TYPE_IN => $this->translator->trans('oro.filter.form.label_type_in'), self::TYPE_NOT_IN => $this->translator->trans('oro.filter.form.label_type_not_in')]]);
     $resolver->setNormalizer('class', function (Options $options, $value) {
         if ($value !== null) {
             return $value;
         }
         if (empty($options['enum_code'])) {
             throw new InvalidOptionsException('Either "class" or "enum_code" must option must be set.');
         }
         $class = ExtendHelper::buildEnumValueClassName($options['enum_code']);
         if (!is_a($class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue', true)) {
             throw new InvalidOptionsException(sprintf('"%s" must be a child of "%s"', $class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue'));
         }
         return $class;
     });
     // this normalizer allows to add/override field_options options outside
     $resolver->setNormalizer('field_options', function (Options $options, $value) use(&$defaultFieldOptions) {
         if (isset($options['class'])) {
             $nullValue = null;
             if ($options->offsetExists('null_value')) {
                 $nullValue = $options->offsetGet('null_value');
             }
             $value['choices'] = $this->getChoices($options['class'], $nullValue);
         } else {
             $value['choices'] = [];
         }
         return array_merge($defaultFieldOptions, $value);
     });
 }
 /**
  * @param OptionsResolver $resolver
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['fields', 'associations', 'callbacks']);
     $fieldsNormalizer = function (Options $options, $fields) {
         $collection = new Collection\FieldMetadataCollection();
         $factory = new FieldMetadataFactory();
         foreach ($fields as $fieldName => $parameters) {
             $fieldMetadata = $factory->create($fieldName, $parameters);
             $collection->add($fieldMetadata);
         }
         return $collection;
     };
     $associationsNormalizer = function (Options $options, $associations) {
         $collection = new Collection\AssociationMetadataCollection();
         $factory = new AssociationMetadataFactory();
         foreach ($associations as $associationName => $parameters) {
             $associationMetadata = $factory->create($associationName, $parameters);
             $collection->add($associationMetadata);
         }
         return $collection;
     };
     $resolver->setNormalizer('fields', $fieldsNormalizer);
     $resolver->setNormalizer('associations', $associationsNormalizer);
     $resolver->setDefaults(['fields' => new Collection\FieldMetadataCollection(), 'associations' => new Collection\AssociationMetadataCollection(), 'callbacks' => []]);
     $resolver->setAllowedTypes('fields', ['array', Collection\FieldMetadataCollection::class]);
     $resolver->setAllowedTypes('associations', ['array', Collection\AssociationMetadataCollection::class]);
     $resolver->setAllowedTypes('callbacks', 'array');
 }
 /**
  * @param OptionsResolver $resolver
  * @throws AccessException
  * @throws UndefinedOptionsException
  * @throws MissingFamilyException
  * @throws \UnexpectedValueException
  * @throws ConstraintDefinitionException
  * @throws InvalidOptionsException
  * @throws MissingOptionsException
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['required' => true, 'constraints' => new NotBlank()]);
     $resolver->setRequired(['attribute', 'parent_data']);
     $resolver->setNormalizer('attribute', function (Options $options, $value) {
         return VariantType::normalizeVariantAttribute($value);
     });
     $resolver->setNormalizer('parent_data', function (Options $options, $value) {
         return VariantType::normalizeParentData($options, $value);
     });
     $resolver->setNormalizer('choices', function (Options $options, $value) {
         $attribute = $options['attribute'];
         $families = [];
         /** @var array $variantFamilies */
         $variantFamilies = $attribute->getOptions()['variant_families'];
         foreach ($variantFamilies as $familyCode) {
             $family = $this->familyConfigurationHandler->getFamily($familyCode);
             if (!$family instanceof VariantFamily) {
                 throw new \UnexpectedValueException("Variant families in attribute options must be of type VariantFamily, '{$family->getCode()}' is not a variant");
             }
             $families[ucfirst($family)] = $family;
         }
         return $families;
     });
 }
Ejemplo n.º 4
0
 private function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['alias', 'source', 'aggregated', 'paginator_source']);
     $resolver->setDefaults(['aggregated' => false, 'paginator_source' => '']);
     $resolver->setNormalizer('aggregated', function (Options $options) {
         return $this->isAggregateColumn($options['source'], ['SUM', 'GROUP_CONCAT', 'MIN', 'MAX', 'AVG', 'COUNT']);
     });
     $resolver->setNormalizer('paginator_source', function (Options $options) {
         return $this->normalizePaginatorSource($options);
     });
 }
Ejemplo n.º 5
0
 public function __construct(array $options)
 {
     $math = new NativeMath();
     $resolver = new OptionsResolver();
     $dimensionsNormalizer = new DimensionsNormalizer($math);
     $resolver->setDefined(['extra_data'])->setDefaults(['currency' => 'USD', 'math' => $math, 'weight_converter' => new WeightConverter($math), 'length_converter' => new LengthConverter($math), 'girth_calculator' => new UspsGirthCalculator($math, $dimensionsNormalizer), 'dimensions_normalizer' => $dimensionsNormalizer, 'extra_data' => null])->setRequired(['export_countries', 'import_countries', 'zone_calculators', 'currency', 'fuel_subcharge', 'math', 'weight_converter', 'length_converter', 'mass_unit', 'dimensions_unit', 'maximum_girth', 'maximum_dimension'])->setAllowedTypes(['export_countries' => 'array', 'import_countries' => 'array', 'zone_calculators' => 'array', 'currency' => 'string', 'math' => MathInterface::class, 'weight_converter' => UnitConverterInterface::class, 'length_converter' => UnitConverterInterface::class, 'girth_calculator' => UspsGirthCalculator::class, 'dimensions_normalizer' => DimensionsNormalizer::class]);
     $resolver->setNormalizer('import_countries', $this->createImportCountriesNormalizer());
     $resolver->setNormalizer('export_countries', $this->createExportCountriesNormalizer());
     $resolver->setNormalizer('zone_calculators', $this->createZoneCalculatorsNormalizer());
     $this->options = $resolver->resolve($options);
 }
Ejemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $defaults = array('image_url' => null, 'widget_type' => $this->widgetType, 'widget_width' => '100px', 'widget_height' => '100px', 'select_label' => 'Select image', 'change_label' => 'Change', 'remove_label' => 'Remove');
     $ajaxDefaults = array('total_class' => null, 'total_id' => null, 'total_property' => null, 'parent_class' => null, 'parent_id' => null, 'parent_property' => null);
     $resolver->setDefaults(array('zkFileSettings' => $defaults, 'zkAjaxSettings' => $ajaxDefaults));
     $resolver->setNormalizer('zkFileSettings', function (Options $options, $configs) use($defaults) {
         return array_merge($defaults, $configs);
     });
     $resolver->setNormalizer('zkAjaxSettings', function (Options $options, $configs) use($ajaxDefaults) {
         return array_merge($ajaxDefaults, $configs);
     });
 }
Ejemplo n.º 7
0
 public function __construct(array $options)
 {
     $math = new NativeMath();
     $resolver = new OptionsResolver();
     $weightConverter = new WeightConverter($math);
     $lengthConverter = new LengthConverter($math);
     $dimensionsNormalizer = new DimensionsNormalizer($math);
     $resolver->setDefined(['extra_data'])->setDefaults(['currency' => 'USD', 'math' => $math, 'weight_converter' => $weightConverter, 'length_converter' => $lengthConverter, 'perimeter_calculator' => new MaximumPerimeterCalculator($math, $dimensionsNormalizer), 'volumetric_weight_calculator' => new IParcelVolumetricWeightCalculator($math, $weightConverter, $lengthConverter), 'dimensions_normalizer' => $dimensionsNormalizer, 'extra_data' => null])->setRequired(['export_countries', 'import_countries', 'zones', 'currency', 'math', 'weight_converter', 'length_converter', 'mass_unit', 'dimensions_unit', 'maximum_perimeter', 'maximum_dimension', 'maximum_weight'])->setAllowedTypes(['export_countries' => 'array', 'import_countries' => 'array', 'zones' => 'array', 'currency' => 'string', 'math' => MathInterface::class, 'weight_converter' => UnitConverterInterface::class, 'length_converter' => UnitConverterInterface::class, 'perimeter_calculator' => MaximumPerimeterCalculator::class, 'volumetric_weight_calculator' => IParcelVolumetricWeightCalculator::class, 'dimensions_normalizer' => DimensionsNormalizer::class]);
     $resolver->setNormalizer('import_countries', $this->createImportCountriesNormalizer());
     $resolver->setNormalizer('export_countries', $this->createExportCountriesNormalizer());
     $resolver->setNormalizer('zones', $this->createZonesNormalizer());
     $this->options = $resolver->resolve($options);
 }
 public function __construct(array $options)
 {
     $math = new NativeMath();
     $resolver = new OptionsResolver();
     $weightConverter = new WeightConverter($math);
     $lengthConverter = new LengthConverter($math);
     $resolver->setDefined(['extra_data'])->setDefaults(['currency' => 'USD', 'math' => $math, 'weight_converter' => $weightConverter, 'length_converter' => $lengthConverter, 'volumetric_weight_calculator' => new DhlVolumetricWeightCalculator($math, $weightConverter, $lengthConverter), 'dimensions_normalizer' => new DimensionsNormalizer($math), 'extra_data' => null])->setRequired(['export_countries', 'import_countries', 'zone_calculators', 'currency', 'math', 'weight_converter', 'length_converter', 'mass_unit', 'dimensions_unit', 'maximum_weight', 'maximum_dimensions'])->setAllowedTypes(['export_countries' => 'array', 'import_countries' => 'array', 'zone_calculators' => 'array', 'currency' => 'string', 'math' => 'Moriony\\Trivial\\Math\\MathInterface', 'weight_converter' => 'Moriony\\Trivial\\Converter\\UnitConverterInterface', 'length_converter' => 'Moriony\\Trivial\\Converter\\UnitConverterInterface', 'volumetric_weight_calculator' => 'EsteIt\\ShippingCalculator\\VolumetricWeightCalculator\\DhlVolumetricWeightCalculator', 'dimensions_normalizer' => 'EsteIt\\ShippingCalculator\\Tool\\DimensionsNormalizer']);
     $resolver->setNormalizer('import_countries', $this->createImportCountriesNormalizer());
     $resolver->setNormalizer('export_countries', $this->createExportCountriesNormalizer());
     $resolver->setNormalizer('zone_calculators', $this->createZoneCalculatorsNormalizer());
     $resolver->setNormalizer('maximum_dimensions', $this->createDimensionsNormalizer());
     $this->options = $resolver->resolve($options);
 }
Ejemplo n.º 9
0
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['id_property' => 'id', 'manager' => null, 'limit' => 20, 'search' => [], 'property' => 'name']);
     $resolver->setNormalizer('search', function (Options $options, $value) {
         if (empty($value) && !empty($options['property'])) {
             $value = [$options['property'] => self::SEARCH_MIDDLE];
         }
         return $value;
     });
     $resolver->setRequired(['class']);
     $resolver->setNormalizer('manager', function (Options $options, $manager) {
         return $this->normalize($options, $manager);
     });
 }
Ejemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('operator' => true, 'sort' => true, 'type' => null, 'value_options' => array()));
     $resolver->setAllowedTypes('value_options', 'array');
     $resolver->setNormalizer('type', function (Options $options, $value) {
         if ($options['operator'] == true && $value === null) {
             throw new MissingOptionsException(sprintf('The required option "type" is missing.'));
         }
         return $value;
     });
     $resolver->setNormalizer('value_options', function (Options $options, $value) {
         return array_merge(array('required' => false), $value);
     });
 }
Ejemplo n.º 11
0
 public function configureOptions(OptionsResolver $resolver)
 {
     $manager = $this->manager;
     $resolver->setNormalizer('query_builder', function (Options $options, $value) use($manager) {
         return $manager->getRepository('EnhavoCategoryBundle:Category')->getByCollectionQuery($options['category_name']);
     });
     $resolver->setDefaults(array('expanded' => true, 'multiple' => true, 'class' => $this->dataClass, 'category_name' => $this->categoryDefaultCollection, 'translation_domain' => 'EnhavoCategoryBundle'));
     $resolver->setNormalizer('label', function (Options $options, $value) {
         if ($options['multiple']) {
             return 'category.label.categories';
         }
         return 'category.label.category';
     });
 }
 private function setNormalizers()
 {
     $this->resolver->setNormalizer(TCO::TEMPLATES, function (Options $options, $value) {
         return $this->makeTemplatePathsAbsolute($value, $options);
     });
     $this->resolver->setNormalizer(TCO::RESOURCES, function (Options $options, $resources) {
         $absolutizedResources = [];
         foreach ($resources as $key => $resource) {
             $key = $options['templatesPath'] . '/' . $key;
             $absolutizedResources[$key] = $resource;
         }
         return $absolutizedResources;
     });
 }
Ejemplo n.º 13
0
 /**
  * @param EventDispatcherInterface $dispatcher
  */
 public function __construct(EventDispatcherInterface $dispatcher)
 {
     $this->dispatcher = $dispatcher;
     $this->specResolver = new OptionsResolver();
     $this->specResolver->setDefaults(array('on' => self::ALL, 'from' => self::ALL, 'to' => self::ALL));
     $this->specResolver->setAllowedTypes('on', array('string', 'array'));
     $this->specResolver->setAllowedTypes('from', array('string', 'array'));
     $this->specResolver->setAllowedTypes('to', array('string', 'array'));
     $toArrayNormalizer = function (Options $options, $value) {
         return (array) $value;
     };
     $this->specResolver->setNormalizer('on', $toArrayNormalizer);
     $this->specResolver->setNormalizer('from', $toArrayNormalizer);
     $this->specResolver->setNormalizer('to', $toArrayNormalizer);
 }
 /**
  * @inheritdoc
  */
 public function configurePayload(OptionsResolver $resolver)
 {
     $resolver->setRequired(0);
     $resolver->setAllowedTypes(0, 'numeric');
     $resolver->setNormalizer(0, function (Options $options, $value) {
         if (null === ($listing = $this->scheduler->findFeed($value))) {
             throw new InvalidArgumentException(sprintf('Feed with id "%d" does not exist', $value));
         }
         return $listing;
     });
     $resolver->setDefaults([1 => false]);
     $resolver->setNormalizer(1, function (Options $options, $value) {
         return (bool) $value;
     });
 }
Ejemplo n.º 15
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $entryOptionsNormalizer = function (Options $options, $value) {
         $value['block_name'] = 'entry';
         return $value;
     };
     $optionsNormalizer = function (Options $options, $value) use($entryOptionsNormalizer) {
         if (null !== $value) {
             @trigger_error('The form option "options" is deprecated since version 2.8 and will be removed in 3.0. Use "entry_options" instead.', E_USER_DEPRECATED);
         }
         return $entryOptionsNormalizer($options, $value);
     };
     $typeNormalizer = function (Options $options, $value) {
         if (null !== $value) {
             @trigger_error('The form option "type" is deprecated since version 2.8 and will be removed in 3.0. Use "entry_type" instead.', E_USER_DEPRECATED);
         }
     };
     $entryType = function (Options $options) {
         if (null !== $options['type']) {
             return $options['type'];
         }
         return __NAMESPACE__ . '\\TextType';
     };
     $entryOptions = function (Options $options) {
         if (1 === count($options['options']) && isset($options['block_name'])) {
             return array();
         }
         return $options['options'];
     };
     $resolver->setDefaults(array('allow_add' => false, 'allow_delete' => false, 'prototype' => true, 'prototype_data' => null, 'prototype_name' => '__name__', 'type' => null, 'options' => null, 'entry_type' => $entryType, 'entry_options' => $entryOptions, 'delete_empty' => false));
     $resolver->setNormalizer('options', $optionsNormalizer);
     $resolver->setNormalizer('entry_options', $entryOptionsNormalizer);
 }
Ejemplo n.º 16
0
 /**
  * @param StateMachineInterface $stateMachine
  */
 private function loadTransitions(StateMachineInterface $stateMachine)
 {
     $resolver = new OptionsResolver();
     $resolver->setRequired(array('from', 'to'));
     $resolver->setDefaults(array('guard' => null));
     $resolver->setNormalizer('from', function (Options $options, $v) {
         return (array) $v;
     });
     $resolver->setNormalizer('guard', function (Options $options, $v) {
         return !isset($v) ? null : $v;
     });
     foreach ($this->config['transitions'] as $transition => $config) {
         $config = $resolver->resolve($config);
         $stateMachine->addTransition(new Transition($transition, $config['from'], $config['to'], $config['guard']));
     }
 }
Ejemplo n.º 17
0
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('label' => 'resource', 'attr' => $this->defaultAttributes, 'display_view_button' => true, 'display_browse_button' => true, 'display_download_button' => true));
     $resolver->setNormalizer('attr', function (Options $options, $value) {
         return array_merge($this->defaultAttributes, $value);
     });
 }
 private function setNormalizers()
 {
     $this->resolver->setNormalizer(CO::ANNOTATION_GROUPS, function (Options $options, $value) {
         $value = (array) $value;
         if ($options[CO::DEPRECATED]) {
             $value[] = CO::DEPRECATED;
         }
         if ($options[CO::TODO]) {
             $value[] = CO::TODO;
         }
         return array_unique($value);
     });
     $this->resolver->setNormalizer(CO::DESTINATION, function (Options $options, $value) {
         return $this->fileSystem->getAbsolutePath($value);
     });
     $this->resolver->setNormalizer(CO::BASE_URL, function (Options $options, $value) {
         return rtrim($value, '/');
     });
     $this->resolver->setNormalizer(CO::SOURCE, function (Options $options, $value) {
         if (!is_array($value)) {
             $value = [$value];
         }
         foreach ($value as $key => $source) {
             $value[$key] = $this->fileSystem->getAbsolutePath($source);
         }
         return $value;
     });
     $this->resolver->setNormalizer(CO::SOURCE_CODE, function (Options $options) {
         return !$options[CO::NO_SOURCE_CODE];
     });
     $this->resolver->setNormalizer(CO::TEMPLATE_CONFIG, function (Options $options, $value) {
         return $this->fileSystem->getAbsolutePath($value);
     });
 }
 public function configureOptions(OptionsResolver $resolver)
 {
     // Les valeurs par défault
     $resolver->setDefaults(array("host" => "smtp.example.org", "username" => "user", "password" => 'pa$$word', "port" => "25", 'encryption' => null));
     // Les options obligatoire
     $resolver->setRequired(array('host', 'username', 'password'));
     // Les type de valeur autorisé pour le port
     $resolver->setAllowedTypes("port", array("int"));
     // Les valeur autorisé pour l'username
     $resolver->setAllowedValues("username", array("john", "doe", "johndoe"));
     // On normalise le host en fornction de l'encryption ssl ou non
     $resolver->setNormalizer("host", function (Options $options, $value) {
         if (!in_array(substr($value, 0, 7), array("http://", "https://"))) {
             if ("ssl" === $options["encryption"]) {
                 $value = "https://" . $value;
             } else {
                 $value = "http://" . $value;
             }
             return $value;
         }
     });
     // On change la valeur par défault du port en fonction de l'encryption ssl ou non
     $resolver->setDefault("port", function (Options $options) {
         if ("ssl" === $options["encryption"]) {
             return 465;
         }
         return 25;
     });
 }
Ejemplo n.º 20
0
    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        // Make sure that validation groups end up as null, closure or array
        $validationGroupsNormalizer = function (Options $options, $groups) {
            if (false === $groups) {
                return array();
            }

            if (empty($groups)) {
                return;
            }

            if (is_callable($groups)) {
                return $groups;
            }

            if ($groups instanceof GroupSequence) {
                return $groups;
            }

            return (array) $groups;
        };

        $resolver->setDefaults(array(
            'validation_groups' => null,
        ));

        $resolver->setNormalizer('validation_groups', $validationGroupsNormalizer);
    }
Ejemplo n.º 21
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('expanded' => true));
     $resolver->setNormalizer('choices', function () {
         return array('attr1' => 'Attribute 1', 'attr2' => 'Attribute 2');
     });
 }
Ejemplo n.º 22
0
 /**
  * Configures the options for this type.
  *
  * @param OptionsResolver $resolver The resolver for the options.
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('border' => false, 'sortable' => false, 'sortable_property' => 'position', 'prototype' => true, 'allow_add' => true, 'by_reference' => false, 'allow_delete' => true));
     $resolver->setNormalizer('prototype_name', function (Options $options, $value) {
         return '__' . $options['type'] . '__';
     });
 }
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('em' => null, 'property' => null, 'queryBuilder' => null, 'multiple' => true, 'values_delimiter' => ','))->setAllowedValues('multiple', [true, false])->setRequired(array('class'));
     $registry = $this->registry;
     $resolver->setNormalizer('em', function (Options $options, $em) use($registry) {
         if (null !== $em) {
             if ($em instanceof EntityManager) {
                 return $em;
             } elseif (is_string($em)) {
                 $em = $registry->getManager($em);
             } else {
                 throw new FormException(sprintf('Option "em" should be a string or entity manager object, %s given', is_object($em) ? get_class($em) : gettype($em)));
             }
         } else {
             $em = $registry->getManagerForClass($options['class']);
         }
         if (null === $em) {
             throw new FormException(sprintf('Class "%s" is not a managed Doctrine entity. Did you forget to map it?', $options['class']));
         }
         return $em;
     })->setNormalizer('queryBuilder', function (Options $options, $queryBuilder) {
         if (null !== $queryBuilder && !is_callable($queryBuilder)) {
             throw new FormException(sprintf('Option "queryBuilder" should be a callable, %s given', is_object($queryBuilder) ? get_class($queryBuilder) : gettype($queryBuilder)));
         }
         return $queryBuilder;
     });
 }
Ejemplo n.º 24
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['choice_label' => 'name', 'choices_as_values' => true]);
     $resolver->setNormalizer('choices', function () {
         //            var_dump($this->repository->findAll()); die;
         return $this->repository->findAll();
     });
 }
Ejemplo n.º 25
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $translator = $this->translator;
     $translationDomain = $this->translationDomain;
     $resolver->setNormalizer('post_max_size_message', function (Options $options, $errorMessage) use($translator, $translationDomain) {
         return $translator->trans($errorMessage, array(), $translationDomain);
     });
 }
Ejemplo n.º 26
0
 /**
  * {@inheritdoc}
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['alias', 'source', 'aggregated']);
     $resolver->setDefaults(['aggregated' => false]);
     $resolver->setNormalizer('aggregated', function ($options) {
         return $this->isAggregateColumn($options['source']);
     });
 }
Ejemplo n.º 27
0
 /**
  * Resolve amount option
  *
  * @param OptionsResolver $resolver
  */
 protected function setCustomerInfoResolver(OptionsResolver $resolver)
 {
     $resolver->setAllowedTypes('customer_info', Customer::class);
     /** @noinspection PhpUnusedParameterInspection */
     $resolver->setNormalizer('customer_info', function (Options $options, Customer $value) {
         return $value->serialize();
     });
 }
Ejemplo n.º 28
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $defaultConfigs = ['placeholder' => 'oro.activity.contexts.placeholder', 'allowClear' => true, 'multiple' => true, 'separator' => ';', 'forceSelectedData' => true, 'minimumInputLength' => 0];
     $resolver->setDefaults(['tooltip' => false, 'configs' => $defaultConfigs]);
     $resolver->setNormalizer('configs', function (Options $options, $configs) use($defaultConfigs) {
         return array_replace_recursive($defaultConfigs, $configs);
     });
 }
Ejemplo n.º 29
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $optionsNormalizer = function (Options $options, $value) {
         $value['block_name'] = 'entry';
         return $value;
     };
     $resolver->setDefaults(array('allow_add' => false, 'allow_delete' => false, 'prototype' => true, 'prototype_name' => '__name__', 'type' => 'text', 'options' => array(), 'delete_empty' => false));
     $resolver->setNormalizer('options', $optionsNormalizer);
 }
Ejemplo n.º 30
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $entryOptionsNormalizer = function (Options $options, $value) {
         $value['block_name'] = 'entry';
         return $value;
     };
     $resolver->setDefaults(array('allow_add' => false, 'allow_delete' => false, 'prototype' => true, 'prototype_data' => null, 'prototype_name' => '__name__', 'entry_type' => __NAMESPACE__ . '\\TextType', 'entry_options' => array(), 'delete_empty' => false));
     $resolver->setNormalizer('entry_options', $entryOptionsNormalizer);
 }