/**
  * @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,
             'exclude_from' => array(),
             'exclude_to'   => array(),
         )
     );
     $this->specResolver->setAllowedTypes(
         array(
             'on'           => array('string', 'array'),
             'from'         => array('string', 'array'),
             'to'           => array('string', 'array'),
             'exclude_from' => array('string', 'array'),
             'exclude_to'   => array('string', 'array'),
         )
     );
     $toArrayNormalizer = function (Options $options, $value) {
         return (array)$value;
     };
     $this->specResolver->setNormalizers(
         array(
             'on'           => $toArrayNormalizer,
             'from'         => $toArrayNormalizer,
             'to'           => $toArrayNormalizer,
             'exclude_to'   => $toArrayNormalizer,
             'exclude_from' => $toArrayNormalizer,
         )
     );
 }
 /**
  * {@inheritdoc}
  */
 public function configureResolver(OptionsResolverInterface $resolver)
 {
     $patientNormalizer = function (Options $options, $value) {
         static $resource;
         if (!$resource) {
             $resource = $options['patient_resource']->getRepository();
         }
         return $resource->getByMRN($value);
     };
     $codes = $this->getCodes();
     $diagnosisNormalizer = function (Options $options, $value) use($codes) {
         static $resource;
         if (!$resource) {
             $resource = $options['diagnosis_resource']->getRepository();
         }
         if ($patient = $options['patient']) {
             foreach ($patient->getDiagnoses() as $diagnosis) {
                 if (in_array($diagnosis->getCode()->getCode(), $codes)) {
                     return $diagnosis;
                 }
             }
         }
     };
     $dateNormalizer = function (Options $options, $value) {
         return empty($value) ? null : new DateTime($value);
     };
     $resolver->setRequired(array('patient', 'activity_date'));
     $resolver->setOptional(array('diagnosis'));
     $resolver->setAllowedTypes(array('patient' => array('string'), 'diagnosis' => array('Accard\\Component\\Diagnosis\\Model\\DiagnosisInterface', 'null'), 'activity_date' => array('string', 'null')));
     $resolver->setNormalizers(array('patient' => $patientNormalizer, 'diagnosis' => $diagnosisNormalizer, 'activity_date' => $dateNormalizer));
 }
Example #3
0
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('attr' => $this->defaultAttributes));
     $resolver->setNormalizers(array('attr' => function (Options $options, $value) {
         return array_merge($this->defaultAttributes, $value);
     }));
 }
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $defaultFieldOptions = ['multiple' => true];
     $resolver->setDefaults(['dictionary_code' => null, 'class' => null, 'field_options' => $defaultFieldOptions]);
     $resolver->setNormalizers(['class' => function (Options $options, $value) {
         if ($value !== null) {
             return $value;
         }
         if (empty($options['dictionary_code'])) {
             throw new InvalidOptionsException('Either "class" or "dictionary_code" must option must be set.');
         }
         $class = ExtendHelper::buildEnumValueClassName($options['dictionary_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;
     }, 'field_options' => function (Options $options, $value) use(&$defaultFieldOptions) {
         if (isset($options['class'])) {
             $nullValue = null;
             if ($options->has('null_value')) {
                 $nullValue = $options->get('null_value');
             }
             $value['choices'] = $this->getChoices($options['class'], $nullValue);
         } else {
             $value['choices'] = [];
         }
         return array_merge($defaultFieldOptions, $value);
     }]);
 }
Example #5
0
 /**
  * (non-PHPdoc)
  * @see Symfony\Component\Form.AbstractType::setDefaultOptions()
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('translation_domain' => 'NeutronFormBundle', 'date_format' => \IntlDateFormatter::LONG, 'date_pattern' => null, 'time_format' => \IntlDateFormatter::MEDIUM));
     $resolver->setNormalizers(array('read_only' => function (Options $options, $value) {
         return true;
     }));
 }
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     if (!$this->channelClass) {
         throw new \InvalidArgumentException('Channel class is missing');
     }
     $queryBuilderNormalizer = function (Options $options, $qb) {
         /** @var EntityManager $em */
         $em = $options['em'];
         /** @var EntityRepository $repository */
         $repository = $em->getRepository($this->channelClass);
         $entities = $options->get('entities');
         /** @var QueryBuilder $queryBuilder */
         $queryBuilder = $qb($repository, $entities);
         $queryBuilder->join('c.dataSource', 'd')->andWhere($queryBuilder->expr()->andX($queryBuilder->expr()->eq('d.type', ':type'), $queryBuilder->expr()->eq('d.enabled', ':enabled')))->setParameter('type', ChannelType::TYPE)->setParameter('enabled', true);
         $filteredQb = clone $queryBuilder;
         /** @var Channel[] $channels */
         $channels = $filteredQb->getQuery()->getResult();
         $skipEntities = [];
         foreach ($channels as $channel) {
             $dataSource = $channel->getDataSource();
             if (!(bool) $dataSource->getSynchronizationSettings()->offsetGetOr('isTwoWaySyncEnabled')) {
                 $skipEntities[] = $channel->getId();
             }
         }
         if ($skipEntities) {
             $queryBuilder->andWhere($queryBuilder->expr()->notIn('c.id', ':skipEntities'))->setParameter('skipEntities', $skipEntities);
         }
         return $queryBuilder;
     };
     $resolver->setNormalizers(['query_builder' => $queryBuilderNormalizer]);
 }
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('em' => null, 'property' => null, 'queryBuilder' => null, 'multiple' => true, 'values_delimiter' => ','))->setAllowedValues(array('multiple' => array(true, false)));
     $resolver->setRequired(array('class'));
     $registry = $this->registry;
     $emNormalizer = 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;
     };
     $queryBuilderNormalizer = 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;
     };
     $resolver->setNormalizers(array('em' => $emNormalizer, 'queryBuilder' => $queryBuilderNormalizer));
 }
Example #8
0
 /**
  * {@inheritDoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('entity_class' => null, 'config_id' => null));
     $resolver->setNormalizers(array('choices' => function (Options $options, $value) {
         if (!empty($value)) {
             return $value;
         }
         $entityClass = $options['entity_class'];
         if (!$entityClass && $options->has('config_id')) {
             $configId = $options['config_id'];
             if ($configId && $configId instanceof ConfigIdInterface) {
                 $entityClass = $configId->getClassName();
             }
         }
         $choices = array();
         if ($entityClass) {
             /** @var WorkflowDefinition[] $definitions */
             $definitions = $this->registry->getRepository('OroWorkflowBundle:WorkflowDefinition')->findBy(array('relatedEntity' => $entityClass));
             foreach ($definitions as $definition) {
                 $name = $definition->getName();
                 $label = $definition->getLabel();
                 $choices[$name] = $label;
             }
         }
         return $choices;
     }));
 }
 /**
  * {@inheritDoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $uploadConfig = array('uploadRoute' => 'comur_api_upload', 'uploadUrl' => null, 'webDir' => null, 'fileExt' => '*.jpg;*.gif;*.png;*.jpeg', 'libraryDir' => null, 'libraryRoute' => 'comur_api_image_library', 'showLibrary' => true, 'saveOriginal' => false, 'generateFilename' => true);
     $cropConfig = array('minWidth' => 1, 'minHeight' => 1, 'aspectRatio' => true, 'cropRoute' => 'comur_api_crop', 'forceResize' => true, 'thumbs' => null);
     $resolver->setDefaults(array('uploadConfig' => $uploadConfig, 'cropConfig' => $cropConfig, 'inherit_data' => true));
     $isGallery = $this->isGallery;
     $galleryDir = $this->galleryDir;
     $resolver->setNormalizers(array('uploadConfig' => function (Options $options, $value) use($uploadConfig, $isGallery, $galleryDir) {
         $config = array_merge($uploadConfig, $value);
         if ($isGallery) {
             $config['uploadUrl'] = $config['uploadUrl'] . '/' . $galleryDir;
             $config['webDir'] = $config['webDir'] . '/' . $galleryDir;
             $config['saveOriginal'] = false;
         }
         if (!isset($config['libraryDir'])) {
             $config['libraryDir'] = $config['uploadUrl'];
         }
         // if($config['saveOriginal']){
         //     $options['compound']=true;
         // }
         return $config;
     }, 'cropConfig' => function (Options $options, $value) use($cropConfig) {
         return array_merge($cropConfig, $value);
     }));
 }
Example #10
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $defaultConfigs = ['placeholder' => 'oro.entity.form.choose_entity', 'result_template_twig' => 'OroEntityBundle:Choice:entity/result.html.twig', 'selection_template_twig' => 'OroEntityBundle:Choice:entity/selection.html.twig'];
     $resolver->setDefaults(['choices' => function (Options $options) {
         return $this->getChoices($options['show_plural']);
     }, 'choice_attr' => function ($choice) {
         return $this->getChoiceAttributes($choice);
     }, 'empty_value' => '', 'show_plural' => false, 'configs' => $defaultConfigs, 'translatable_options' => false, 'group_by' => function () {
         // @codingStandardsIgnoreStart
         /**
          * This option was added since duplicated values are removed otherwise
          * (which happens if there are at least 2 entities having the same translations in
          * currently used language)
          *
          * Groups are created by flipping choices first
          * https://github.com/symfony/symfony/blob/c25e054d9e6b376d1f242e9d92454e7037bc4c01/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php#L444
          * then choiceView is created from each group:
          * https://github.com/symfony/symfony/blob/c25e054d9e6b376d1f242e9d92454e7037bc4c01/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php#L174
          */
         // @codingStandardsIgnoreEnd
         return null;
     }]);
     $resolver->setNormalizers(['configs' => function (Options $options, $configs) use($defaultConfigs) {
         return array_merge($defaultConfigs, $configs);
     }]);
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(['multiple' => true, 'expanded' => true, 'choices' => $this->getChoices()]);
     $resolver->setNormalizers(['disabled' => function (Options $options, $value) {
         return $this->isReadOnly($options) ? true : $value;
     }]);
 }
 /**
  * Custom options:
  * - "workflow_item" - required, instance of WorkflowItem entity
  * - "step_name"     - optional, name of step
  *
  * @param OptionsResolverInterface $resolver
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(array('workflow_item'));
     $resolver->setOptional(array('step_name'));
     $resolver->setAllowedTypes(array('step_name' => 'string'));
     $resolver->setNormalizers(array('step_name' => function (Options $options, $stepName) {
         /** @var Workflow $workflow */
         $workflow = $options['workflow'];
         /** @var WorkflowItem $workflowItem */
         $workflowItem = $options['workflow_item'];
         if (!$stepName) {
             $stepName = $workflowItem->getCurrentStepName();
         }
         if (!$workflow->getStepManager()->getStep($stepName)) {
             throw new InvalidConfigurationException(sprintf('Invalid reference to unknown step "%s" of workflow "%s".', $stepName, $workflow->getName()));
         }
         return $stepName;
     }, 'disable_attribute_fields' => function (Options $options, $disableAttributeFields) {
         /** @var Workflow $workflow */
         $workflow = $options['workflow'];
         /** @var WorkflowItem $workflowItem */
         $workflowItem = $options['workflow_item'];
         $step = $workflow->getStepManager()->getStep($options['step_name']);
         if ($step->getName() !== $workflowItem->getCurrentStepName() || $workflowItem->isClosed()) {
             $disableAttributeFields = true;
         }
         return $disableAttributeFields;
     }));
 }
 /**
  * {@inheritDoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['attribute_type']);
     $resolver->setDefaults(['empty_value' => 'orob2b.attribute.attribute_type_constraint.none']);
     $resolver->setNormalizers(['choices' => function (Options $options, $value) {
         if (!empty($value)) {
             return $value;
         }
         $choices = [];
         if ($options['attribute_type'] instanceof AttributeTypeInterface) {
             $constraints = $options['attribute_type']->getOptionalConstraints();
         } elseif (is_string($options['attribute_type'])) {
             $attributeType = $this->attributeTypeRegistry->getTypeByName($options['attribute_type']);
             if (!$attributeType) {
                 throw new \LogicException(sprintf('Attribute type name "%s" is not exist in attribute type registry.', $options['attribute_type']));
             }
             $constraints = $attributeType->getOptionalConstraints();
         } else {
             throw new UnexpectedTypeException($options['attribute_type'], 'OroB2B\\Bundle\\AttributeBundle\\AttributeType\\AttributeTypeInterface or string');
         }
         foreach ($constraints as $choice) {
             $choices[$choice->getAlias()] = 'orob2b.validation.constraint.alias.' . $choice->getAlias();
         }
         return $choices;
     }]);
 }
Example #14
0
 /**
  * (non-PHPdoc)
  * @see Symfony\Component\Form.AbstractType::setDefaultOptions()
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $defaultConfigs = array('showOn' => 'button', 'dateFormat' => 'yy-mm-dd', 'timeFormat' => 'HH:mm', 'showSecond' => false);
     $resolver->setDefaults(array('input' => 'datetime', 'with_seconds' => false, 'use_meridiem' => false, 'date_timezone' => null, 'user_timezone' => null, 'datetime_format' => 'Y-m-d H:i', 'parts' => array('year', 'month', 'day', 'hour', 'minute'), 'translation_domain' => 'NeutronFormBundle', 'configs' => $defaultConfigs));
     $resolver->setNormalizers(array('datetime_format' => function (Options $options, $value) {
         if ($options->has('with_seconds') && $options->get('with_seconds') === true) {
             return $options->get('use_meridiem') === true ? 'Y-m-d h:i:s a' : 'Y-m-d H:i:s';
         }
         return $options->get('use_meridiem') === true ? 'Y-m-d h:i a' : 'Y-m-d H:i';
     }, 'parts' => function (Options $options, $value) {
         if ($options->has('with_seconds') && $options->get('with_seconds') === true) {
             return array('year', 'month', 'day', 'hour', 'minute', 'second');
         }
         return array('year', 'month', 'day', 'hour', 'minute');
     }, 'configs' => function (Options $options, $value) use($defaultConfigs) {
         $configs = array_replace_recursive($defaultConfigs, $value);
         if (!$options->has('with_seconds') || $options->get('with_seconds') === false) {
             $configs['timeFormat'] = $options->get('use_meridiem') === true ? 'hh:mm tt' : 'HH:mm';
             $configs['showSecond'] = false;
         } else {
             $configs['timeFormat'] = $options->get('use_meridiem') === true ? 'hh:mm:ss tt' : 'HH:mm:ss';
             $configs['showSecond'] = true;
         }
         return $configs;
     }));
     $resolver->setAllowedValues(array('input' => array('datetime', 'string', 'timestamp', 'array'), 'datetime_format' => array('Y-m-d H:i:s', 'Y-m-d h:i:s a', 'Y-m-d H:i', 'Y-m-d h:i a')));
 }
 /**
  * Options:
  * - grid_name - name of grid that will be used for entity selection
  * - grid_parameters - parameters need to be passed to grid request
  * - grid_render_parameters - render parameters need to be set for grid rendering
  * - existing_entity_grid_id - grid row field name used as entity identifier
  * - create_enabled - enables new entity creation
  * - create_acl - ACL resource used to determine that create is allowed, by default CREATE for entity used
  * - create_form_route - route name for creation form
  * - create_form_route_parameters - route parameters for create_form_route_parameters
  *
  * {@inheritDoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(['existing_entity_grid_id' => 'id', 'create_enabled' => true, 'create_acl' => null, 'create_form_route' => null, 'create_form_route_parameters' => [], 'grid_name' => null, 'grid_parameters' => [], 'grid_render_parameters' => []]);
     $resolver->setNormalizers(['create_enabled' => function (Options $options, $createEnabled) {
         $createRouteName = $options->get('create_form_route');
         $createEnabled = $createEnabled && !empty($createRouteName);
         if ($createEnabled) {
             $aclName = $options->get('create_acl');
             if (empty($aclName)) {
                 $aclObjectName = 'Entity:' . $options->get('entity_class');
                 $createEnabled = $this->securityFacade->isGranted('CREATE', $aclObjectName);
             } else {
                 $createEnabled = $this->securityFacade->isGranted($aclName);
             }
         }
         return $createEnabled;
     }, 'grid_name' => function (Options $options, $gridName) {
         if (!empty($gridName)) {
             return $gridName;
         }
         $formConfig = $this->configManager->getProvider('form')->getConfig($options->get('entity_class'));
         if ($formConfig->has('grid_name')) {
             return $formConfig->get('grid_name');
         }
         throw new InvalidConfigurationException('The option "grid_name" must be set.');
     }]);
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('constraints' => [new Assert\NotBlank()]));
     $constraintsNormalizer = function (Options $options, $constraints) {
         /** @var FieldConfigId $fieldConfigId */
         $fieldConfigId = $options['config_id'];
         if (!$this->typeHelper->hasEnumCode($fieldConfigId->getClassName(), $fieldConfigId->getFieldName())) {
             // validations of new enum
             $constraints[] = new Assert\Length(['max' => $this->nameGenerator->getMaxEnumCodeSize()]);
             $constraints[] = new Assert\Regex(['pattern' => '/^[\\w- ]*$/', 'message' => self::INVALID_NAME_MESSAGE]);
             $callback = function ($value, ExecutionContext $context) {
                 if (!empty($value)) {
                     $code = ExtendHelper::buildEnumCode($value, false);
                     if (empty($code)) {
                         $context->addViolation(self::INVALID_NAME_MESSAGE, ['{{ value }}' => $value]);
                     }
                 }
             };
             $constraints[] = new Assert\Callback([$callback]);
             $constraints[] = new UniqueEnumName(['entityClassName' => $fieldConfigId->getClassName(), 'fieldName' => $fieldConfigId->getFieldName()]);
         } else {
             // validations of existing enum
             $constraints[] = new Assert\Length(['max' => 255]);
         }
         return $constraints;
     };
     $resolver->setNormalizers(['constraints' => $constraintsNormalizer, 'disabled' => function (Options $options, $value) {
         return $this->isReadOnly($options) ? true : $value;
     }, 'validation_groups' => function (Options $options, $value) {
         return $options['disabled'] ? false : $value;
     }]);
 }
 /**
  * Add the image_path option
  *
  * @param \Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     // Remove id from ace editor wrapper attributes. Id must be generated.
     $wrapperAttrNormalizer = function (Options $options, $aceAttr) {
         if (is_array($aceAttr)) {
             if (array_key_exists('id', $aceAttr)) {
                 unset($aceAttr['id']);
             }
         } else {
             $aceAttr = array();
         }
         return $aceAttr;
     };
     $defaultUnit = $this->defaultUnit;
     $allowedUnits = $this->units;
     $unitNormalizer = function (Options $options, $value) use($defaultUnit, $allowedUnits) {
         if (is_array($value)) {
             return $value;
         }
         if (preg_match('/([0-9\\.]+)\\s*(' . join('|', $allowedUnits) . ')/', $value, $matchedValue)) {
             $value = $matchedValue[1];
             $unit = $matchedValue[2];
         } else {
             $unit = $defaultUnit;
         }
         return array('value' => $value, 'unit' => $unit);
     };
     $resolver->setDefaults(array('required' => false, 'wrapper_attr' => array(), 'width' => 200, 'height' => 200, 'font_size' => 12, 'mode' => 'ace/mode/html', 'theme' => 'ace/theme/monokai', 'tab_size' => null, 'read_only' => null, 'use_soft_tabs' => null, 'use_wrap_mode' => null, 'show_print_margin' => null, 'show_invisibles' => null, 'highlight_active_line' => null));
     $resolver->setAllowedTypes(array('width' => array('integer', 'string', 'array'), 'height' => array('integer', 'string', 'array'), 'mode' => 'string', 'font_size' => 'integer', 'tab_size' => array('integer', 'null'), 'read_only' => array('bool', 'null'), 'use_soft_tabs' => array('bool', 'null'), 'use_wrap_mode' => array('bool', 'null'), 'show_print_margin' => array('bool', 'null'), 'show_invisibles' => array('bool', 'null'), 'highlight_active_line' => array('bool', 'null')));
     $resolver->setNormalizers(array('wrapper_attr' => $wrapperAttrNormalizer, 'width' => $unitNormalizer, 'height' => $unitNormalizer));
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(['allow_add' => true, 'allow_add_after' => false, 'allow_delete' => true, 'by_reference' => false, 'prototype' => true, 'prototype_name' => '__name__', 'extra_fields_message' => 'This form should not contain extra fields: "{{ extra_fields }}"', 'handle_primary' => true, 'show_form_when_empty' => true, 'add_label' => '', 'row_count_add' => 1, 'row_count_initial' => 1]);
     $resolver->setRequired(['type']);
     $resolver->setNormalizers(['show_form_when_empty' => function (Options $options, $value) {
         return !$options['allow_add'] ? false : $value;
     }]);
 }
Example #19
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver, array $defaultOptions)
 {
     $resolver->setDefaults(array('name' => '', 'title' => '', 'params' => array(), 'attrs' => array(), 'data' => null, 'default' => null, 'format' => null, 'width' => null, 'allow_sort' => false, 'allow_filter' => false));
     $resolver->setAllowedTypes(array('name' => 'string', 'title' => 'string', 'params' => array('string', 'array'), 'attrs' => 'array', 'format' => array('null', 'string', 'int', 'callable'), 'data' => array('null', 'array'), 'default' => array('null', 'string'), 'width' => array('null', 'string'), 'allow_sort' => array('bool', 'array'), 'allow_filter' => array('bool', 'array')));
     $resolver->setNormalizers(array('params' => function (OptionsResolverInterface $resolver, $params) {
         return is_string($params) ? array($params) : $params;
     }));
 }
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $defaults = array('form_style' => 'simple', 'help' => false, 'cols' => array('left' => 4, 'right' => 8));
     $resolver->setDefaults(array('form_style' => null, 'help' => null, 'cols' => array('left' => 4, 'right' => 8)));
     $resolver->setNormalizers(array('form_style' => function (Options $options, $form_style) {
         return in_array($form_style, array('simple', 'horizontal', 'inline')) ? $form_style : 'simple';
     }));
 }
Example #21
0
 /**
  * (non-PHPdoc)
  * @see Symfony\Component\Form.AbstractType::setDefaultOptions()
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $defaultConfigs = array('checked_label' => 'label.checked', 'unchecked_label' => 'label.unchecked');
     $resolver->setDefaults(array('translation_domain' => 'NeutronFormBundle', 'configs' => $defaultConfigs));
     $resolver->setNormalizers(array('configs' => function (Options $options, $value) use($defaultConfigs) {
         return array_replace_recursive($defaultConfigs, $value);
     }));
 }
Example #22
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(['model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'format' => 'yyyy-MM-dd', 'widget' => 'single_text', 'placeholder' => 'oro.form.click_here_to_select', 'years' => []]);
     // remove buggy 'placeholder' normalizer. The placeholder must be a string if 'widget' === 'single_text'
     $resolver->setNormalizers(['placeholder' => function (Options $options, $placeholder) {
         return $placeholder;
     }]);
 }
Example #23
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setNormalizers(['disabled' => function (Options $options, $value) {
         return $this->isReadOnly($options) ? true : $value;
     }, 'validation_groups' => function (Options $options, $value) {
         return $options['disabled'] ? false : $value;
     }]);
 }
Example #24
0
 /**
  * {@inheritDoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $optionsNormalizer = function (Options $options, $value) {
         $value = 'BardisCMS\\ContentBlockBundle\\Entity\\ContentSlide';
         return $value;
     };
     $resolver->setNormalizers(array('data_class' => $optionsNormalizer));
 }
Example #25
0
 /**
  * (non-PHPdoc)
  * @see Symfony\Component\Form.AbstractType::setDefaultOptions()
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $defaultConfigs = $this->options;
     $resolver->setDefaults(array('translation_domain' => 'NeutronFormBundle', 'configs' => $defaultConfigs));
     $resolver->setNormalizers(array('configs' => function (Options $options, $value) use($defaultConfigs) {
         $configs = array_replace_recursive($defaultConfigs, $value);
         return $configs;
     }));
 }
Example #26
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $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()));
     $resolver->setNormalizers(array('options' => $optionsNormalizer));
 }
Example #27
0
 /**
  * (non-PHPdoc)
  * @see Symfony\Component\Form.AbstractType::setDefaultOptions()
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('multiple' => false, 'translation_domain' => 'NeutronFormBundle', 'configs' => array()));
     $resolver->setNormalizers(array('expanded' => function (Options $options, $value) {
         return true;
     }, 'configs' => function (Options $options, $value) {
         return $value;
     }));
 }
Example #28
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setNormalizers(['options' => function (Options $options, $options) {
         if (!$options) {
             $options = [];
         }
         $options['single_form'] = false;
         return $options;
     }]);
 }
Example #29
0
 /**
  * {@inheritDoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('field_type' => 'entity', 'field_options' => array(), 'translatable' => false));
     $resolver->setNormalizers(array('field_type' => function (Options $options, $value) {
         if (!empty($options['translatable'])) {
             $value = 'translatable_entity';
         }
         return $value;
     }));
 }
Example #30
0
 /**
  * (non-PHPdoc)
  * @see Symfony\Component\Form.AbstractType::setDefaultOptions()
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $defaultConfigs = array('limit' => 255);
     $resolver->setDefaults(array('configs' => $defaultConfigs, 'translation_domain' => 'NeutronFormBundle'));
     $resolver->setNormalizers(array('configs' => function (Options $options, $value) use($defaultConfigs) {
         $configs = array_replace_recursive($defaultConfigs, $value);
         $configs['type'] = 'textarea';
         return $configs;
     }));
 }