/**
  * @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');
 }
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $optionsResolver)
 {
     $validator = $this->validator;
     $optionsResolver->setDefaults(['validation_groups' => ['Default'], 'constraints' => function (Options $options) use($validator) {
         if (null === $options['model_class'] || null === $options['model_property']) {
             return [];
         }
         // Its possible getting of the Metadata gives an error,
         // but that means the model class was invalid already.
         // Getting a property without metadata will give an empty array
         /** @var ClassMetadata $classMetadata */
         $classMetadata = $validator->getMetadataFor($options['model_class']);
         $propertyMetadata = $classMetadata->getPropertyMetadata($options['model_property']);
         $constraints = [];
         foreach ($propertyMetadata as $metadata) {
             $constraints += $metadata->getConstraints();
         }
         return $constraints;
     }]);
     // BC layer for Symfony 2.7 and 3.0
     if ($optionsResolver instanceof OptionsResolverInterface) {
         $optionsResolver->setAllowedTypes(['constraints' => ['array', 'Symfony\\Component\\Validator\\Constraint'], 'validation_groups' => ['array']]);
     } else {
         $optionsResolver->setAllowedTypes('constraints', ['array', 'Symfony\\Component\\Validator\\Constraint']);
         $optionsResolver->setAllowedTypes('validation_groups', ['array']);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected static function configureOptionResolver(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['host' => '127.0.0.1', 'port' => '6379', 'scheme' => 'tcp']);
     $resolver->setAllowedTypes('host', ['string']);
     $resolver->setAllowedTypes('port', ['string', 'int']);
     $resolver->setAllowedTypes('scheme', ['string']);
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['value_glue' => null, 'value_format' => null, 'empty_value' => null]);
     $resolver->setAllowedTypes('value_glue', ['string', 'null']);
     $resolver->setAllowedTypes('value_format', ['string', 'callable', 'null']);
     $resolver->setAllowedTypes('empty_value', ['string', 'array', 'null']);
 }
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['field', 'form', 'condition']);
     $resolver->setAllowedTypes('field', ElementInterface::class);
     $resolver->setAllowedTypes('form', Form::class);
     $resolver->setAllowedTypes('condition', ConditionInterface::class);
 }
Esempio n. 6
0
 /**
  * Configure options
  *
  * @param OptionsResolver $resolver
  * @return void
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['amount']);
     $resolver->setDefined(['currency', 'terminal', 'credit_card_token', 'payment_id']);
     $resolver->setAllowedTypes('credit_card_token', 'string');
     $resolver->setAllowedTypes('payment_id', 'string');
     $resolver->setNormalizer('currency', function (Options $options, $value) {
         if (!isset($options['payment_id'])) {
             $fields = ['terminal', 'credit_card_token', 'currency'];
             foreach ($fields as $field) {
                 if (!isset($options[$field])) {
                     throw new \InvalidArgumentException(sprintf('The fields "%s" is required', implode(', ', $fields)));
                 }
             }
         }
         return $value;
     });
     $resolver->setNormalizer('payment_id', function (Options $options, $value) {
         $fields = ['currency', 'terminal', 'credit_card_token'];
         foreach ($fields as $field) {
             if (isset($options[$field])) {
                 throw new \InvalidArgumentException(sprintf('The fields "%s" is not allowed when "payment_id" is set', implode(', ', $fields)));
             }
         }
         return $value;
     });
 }
Esempio n. 7
0
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['label' => false, 'name' => '', 'data_class' => 'RZ\\Roadiz\\Core\\Entities\\Folder', 'attr' => ['class' => 'uk-form folder-form']]);
     $resolver->setRequired(['em']);
     $resolver->setAllowedTypes('em', 'Doctrine\\Common\\Persistence\\ObjectManager');
     $resolver->setAllowedTypes('name', 'string');
 }
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['column_transformers', 'cache']);
     $resolver->setDefaults(['column_transformers' => new ColumnTransformerCollection(), 'cache' => true]);
     $resolver->setAllowedTypes('column_transformers', ColumnTransformerCollection::class);
     $resolver->setAllowedTypes('cache', 'bool');
 }
Esempio n. 9
0
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['compound' => true, 'label' => false, 'nodeName' => null, 'attr' => ['class' => 'uk-form transtype-form']]);
     $resolver->setRequired(['em', 'currentType']);
     $resolver->setAllowedTypes('em', 'Doctrine\\Common\\Persistence\\ObjectManager');
     $resolver->setAllowedTypes('currentType', 'RZ\\Roadiz\\Core\\Entities\\NodeType');
 }
 /**
  * Option configuration.
  *
  * @param OptionsResolver $resolver
  */
 private function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefault('url', 'https://news.google.com/news?cf=all&hl=en&ned=us&topic=t&output=rss');
     $resolver->setAllowedTypes('url', array('string'));
     $resolver->setRequired(array('location_id'));
     $resolver->setAllowedTypes('location_id', array('int'));
 }
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['controller_body' => null, 'angular_modules' => [], 'angular_services' => ['$scope']]);
     $resolver->setAllowedTypes('controller_body', ['null', 'string']);
     $resolver->setAllowedTypes('angular_modules', ['array']);
     $resolver->setAllowedTypes('angular_services', ['array']);
 }
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['route', 'group_action']);
     $resolver->setDefaults(['route' => false, 'group_action' => false]);
     $resolver->setAllowedTypes('route', ['bool', 'string']);
     $resolver->setAllowedTypes('group_action', ['bool', 'string']);
 }
Esempio n. 13
0
 /**
  * Configure options
  *
  * @param OptionsResolver $resolver
  *
  * @throws \Symfony\Component\OptionsResolver\Exception\ExceptionInterface
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['name' => null, 'label' => null, 'entity' => null]);
     $resolver->setAllowedTypes('name', 'string');
     $resolver->setAllowedTypes('label', ['string', 'null']);
     $resolver->setAllowedTypes('entity', 'string');
 }
 /**
  * Set up the configurations of options
  * passed as argument into the following methods of this class :
  * - getWeekDates
  * - getWeekMeals
  */
 private function configureWeekMealOptions()
 {
     $this->weekMealResolver->setDefined(array('date_day', 'without_pork', 'enable_next_week', 'days_ofweek_off', 'dates_off'));
     $this->weekMealResolver->setAllowedTypes('date_day', \DateTimeInterface::class);
     $this->weekMealResolver->setDefaults(array('without_pork' => false, 'enable_next_week' => false, 'days_ofweek_off' => array(Day::WEEK_WEDNESDAY), 'dates_off' => array()));
     $this->weekMealResolver->setRequired(array('without_pork', 'date_day'));
 }
Esempio n. 15
0
 public function configureOptions(OptionsResolver $options)
 {
     $options->setDefaults(['field_options' => []]);
     $options->setRequired(['field_type']);
     $options->setAllowedTypes('field_type', ['string']);
     $options->setAllowedTypes('field_options', ['array']);
 }
Esempio n. 16
0
 /**
  * {@inheritdoc}
  */
 public function build($configuration, array $data)
 {
     $this->configuration = $configuration;
     $resolver = new OptionsResolver();
     $resolver->setRequired(array('key', 'files'));
     $resolver->setDefaults(array('backend' => null, 'passphrase' => false, 'encrypted_extension' => 'crypted'));
     $resolver->setAllowedTypes('key', 'string');
     $resolver->setAllowedTypes('encrypted_extension', 'string');
     $resolver->setAllowedTypes('files', 'array');
     $data = $resolver->resolve($data);
     $key = $data['key'];
     if (strpos($key, 'file://') === 0) {
         $this->keyFile = $key;
         $absoluteKeyFile = $this->getAbsoluteKeyFile();
         if (file_exists($absoluteKeyFile)) {
             $key = file_get_contents($this->getAbsoluteKeyFile());
         }
     }
     $this->key = $key;
     if (!$key) {
         throw new \LogicException(sprintf('Key cannot be retrieved (path = "%s")', $data['key']));
     }
     $this->key = $key;
     $this->needsPassphrase = $data['passphrase'];
     foreach ($data['files'] as $path) {
         $this->files->add(new Resource\File($path, $this->getEncryptedExtension()));
     }
 }
 /**
  * {@inheritdoc}
  */
 protected static function configureOptionResolver(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['host' => '127.0.0.1', 'port' => '8087', 'type' => null]);
     $resolver->setAllowedTypes('host', ['string']);
     $resolver->setAllowedTypes('port', ['string', 'int']);
     $resolver->setAllowedTypes('type', ['string', 'null']);
 }
 /**
  * @param OptionsResolverInterface $resolver
  */
 public function setOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('type' => 'pagekit.component.list'));
     $resolver->setRequired(array('area', 'resource'));
     $resolver->setAllowedTypes('area', "\\Bigfish\\Bundle\\PagekitBundle\\Entity\\Area");
     $resolver->setAllowedTypes('resource', "\\Bigfish\\Bundle\\ResourceBundle\\Entity\\Resource");
 }
 /**
  * @param OptionsResolver $resolver
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['module', 'number', 'dependencyMap']);
     $resolver->setAllowedTypes('module', 'string');
     $resolver->setAllowedTypes('number', 'int');
     $resolver->setAllowedTypes('dependencyMap', 'array');
 }
Esempio n. 20
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired('template');
     $resolver->setAllowedTypes('template', 'string');
     $resolver->setDefined('vars');
     $resolver->setAllowedTypes('vars', 'array');
 }
 /**
  * @inheritdoc
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['template_append' => null, 'template_prepend' => null, 'template_parameters' => []]);
     $resolver->setAllowedTypes('template_append', ['null', 'string']);
     $resolver->setAllowedTypes('template_prepend', ['null', 'string']);
     $resolver->setAllowedTypes('template_parameters', ['array']);
 }
Esempio n. 22
0
 /**
  * {@inheritdoc}
  */
 public function configure(OptionsResolver $options)
 {
     $options->setDefaults(['times' => [10], 'spread' => [0], 'memories' => null]);
     $options->setAllowedTypes('times', 'array');
     $options->setAllowedTypes('spread', 'array');
     $options->setAllowedTypes('memories', ['null', 'array']);
 }
Esempio n. 23
0
 /**
  * {@inheritdoc}
  */
 protected static function configureOptionResolver(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['host' => '127.0.0.1', 'port' => 11211, 'redundant_servers' => []]);
     $resolver->setAllowedTypes('host', ['string']);
     $resolver->setAllowedTypes('port', ['string', 'int']);
     $resolver->setAllowedTypes('redundant_servers', ['array']);
 }
Esempio n. 24
0
 /**
  * {@inheritdoc}
  *
  * - **format** (_boolean_) Format of the resulting archive: tar or zip
  * - **prefix** (_boolean_) Prepend prefix/ to each filename in the archive
  */
 public function setDefaultOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('format' => null, 'prefix' => null));
     $resolver->setAllowedTypes('format', array('null', 'string'));
     $resolver->setAllowedTypes('prefix', array('null', 'string'));
     $resolver->setAllowedValues('format', array('tar', 'zip'));
 }
Esempio n. 25
0
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['route' => null, 'route_parameters' => [], 'data_class' => 'Surfnet\\StepupBundle\\Command\\SwitchLocaleCommand']);
     $resolver->setRequired(['route']);
     $resolver->setAllowedTypes('route', 'string');
     $resolver->setAllowedTypes('route_parameters', 'array');
 }
Esempio n. 26
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('class' => '', 'padding' => '', 'name' => '', 'orderable' => true, 'render' => 'render_boolean', 'searchable' => true, 'title' => '', 'type' => '', 'visible' => true, 'width' => '', 'search_type' => 'like', 'filter_type' => 'select', 'filter_options' => array('' => 'Any', '1' => 'Yes', '0' => 'No'), 'filter_property' => '', 'filter_search_column' => '', 'true_icon' => '', 'false_icon' => '', 'true_label' => '', 'false_label' => ''));
     $resolver->setAllowedTypes('class', 'string');
     $resolver->setAllowedTypes('padding', 'string');
     $resolver->setAllowedTypes('name', 'string');
     $resolver->setAllowedTypes('orderable', 'bool');
     $resolver->setAllowedTypes('render', 'string');
     $resolver->setAllowedTypes('searchable', 'bool');
     $resolver->setAllowedTypes('title', 'string');
     $resolver->setAllowedTypes('type', 'string');
     $resolver->setAllowedTypes('visible', 'bool');
     $resolver->setAllowedTypes('width', 'string');
     $resolver->setAllowedTypes('search_type', 'string');
     $resolver->setAllowedTypes('filter_type', 'string');
     $resolver->setAllowedTypes('filter_options', 'array');
     $resolver->setAllowedTypes('filter_property', 'string');
     $resolver->setAllowedTypes('filter_search_column', 'string');
     $resolver->setAllowedTypes('true_icon', 'string');
     $resolver->setAllowedTypes('false_icon', 'string');
     $resolver->setAllowedTypes('true_label', 'string');
     $resolver->setAllowedTypes('false_label', 'string');
     $resolver->setAllowedValues('search_type', array('like', 'notLike', 'eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'in', 'notIn', 'isNull', 'isNotNull'));
     $resolver->setAllowedValues('filter_type', array('text', 'select'));
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('type' => 'text', 'options' => array(), 'first_options' => array(), 'second_options' => array(), 'first_name' => 'first', 'second_name' => 'second', 'error_bubbling' => false));
     $resolver->setAllowedTypes('options', 'array');
     $resolver->setAllowedTypes('first_options', 'array');
     $resolver->setAllowedTypes('second_options', 'array');
 }
 /**
  * @inheritdoc
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['toggle' => null, 'toggle_prefix' => null, 'toggle_reverse_prefix' => null, 'toggle_group' => null]);
     $resolver->setAllowedTypes('toggle', ['null', 'string']);
     $resolver->setAllowedTypes('toggle_prefix', ['null', 'string']);
     $resolver->setAllowedTypes('toggle_reverse_prefix', ['null', 'string']);
     $resolver->setAllowedTypes('toggle_group', ['null', 'string', 'array']);
 }
 /**
  * @inheritdoc
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['class']);
     $resolver->setDefaults(['data_class' => null, 'invalid_message' => 'The document does not exist.', 'property' => 'id', 'em' => 'default']);
     $resolver->setAllowedTypes('invalid_message', ['null', 'string']);
     $resolver->setAllowedTypes('property', ['null', 'string']);
     $resolver->setAllowedTypes('em', ['null', 'string', ObjectManager::class]);
 }
 /**
  * @inheritdoc
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['select2' => true, 'select2_options' => [], 'select2_template_result' => null, 'select2_template_selection' => null]);
     $resolver->setAllowedTypes('select2', ['boolean']);
     $resolver->setAllowedTypes('select2_options', ['null', 'array']);
     $resolver->setAllowedTypes('select2_template_result', ['null', 'string', 'callable']);
     $resolver->setAllowedTypes('select2_template_selection', ['null', 'string', 'callable']);
 }