function it_should_define_assigned_data_class(OptionsResolverInterface $resolver) { $resolver->setDefaults(array('data_class' => 'Rule', 'validation_groups' => array('sylius')))->shouldBeCalled(); $resolver->setOptional(array('configuration_type'))->shouldBeCalled(); $resolver->setDefaults(array('configuration_type' => RuleInterface::TYPE_ITEM_TOTAL))->shouldBeCalled(); $this->setDefaultOptions($resolver); }
/** * @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, ) ); }
/** * consume * * @param array $options Parameters sent to the processor * * @return void */ public function consume(array $options = array()) { if (null !== $this->logger) { $this->logger->debug(sprintf('Start consuming queue %s.', $this->messageProvider->getQueueName())); } $this->optionsResolver->setDefaults(array('poll_interval' => 50000)); if ($this->processor instanceof ConfigurableInterface) { $this->processor->setDefaultOptions($this->optionsResolver); } $options = $this->optionsResolver->resolve($options); if ($this->processor instanceof InitializableInterface) { $this->processor->initialize($options); } while (true) { while (null !== ($message = $this->messageProvider->get())) { if (false === $this->processor->process($message, $options)) { break 2; } } if ($this->processor instanceof SleepyInterface) { if (false === $this->processor->sleep($options)) { break; } } usleep($options['poll_interval']); } if ($this->processor instanceof TerminableInterface) { $this->processor->terminate($options); } }
function it_should_define_assigned_data_class(OptionsResolverInterface $resolver) { $resolver->setDefaults(array('data_class' => 'Action', 'validation_groups' => array('sylius')))->shouldBeCalled(); $resolver->setOptional(array('configuration_type'))->shouldBeCalled(); $resolver->setDefaults(array('configuration_type' => ActionInterface::TYPE_FIXED_DISCOUNT))->shouldBeCalled(); $this->setDefaultOptions($resolver); }
public function setDefaultOptions(OptionsResolverInterface $resolver) { if ($this->routeName != "miw_rest_user_newuser") { $resolver->setDefaults(array('data_class' => $this->class, 'intention' => 'registration')); } else { $resolver->setDefaults(array('data_class' => $this->class, 'intention' => 'registration', 'csrf_protection' => false)); } }
public function setDefaultOptions(OptionsResolverInterface $resolver) { if ($this->editMode) { $resolver->setDefaults(array('class' => 'FormaLibre\\ReservationBundle\\Entity\\Reservation', 'translation_domain' => 'reservation', 'constraints' => new ReservationModify())); } else { $resolver->setDefaults(array('class' => 'FormaLibre\\ReservationBundle\\Entity\\Reservation', 'translation_domain' => 'reservation', 'constraints' => new Reservation())); } }
public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setRequired(['praticiensChoices']); $resolver->setDefaults(['praticiensChoices' => array()]); $resolver->setRequired(['motifChoices']); $resolver->setDefaults(['motifChoices' => array()]); $resolver->setRequired(['echantillonChoices']); $resolver->setDefaults(['echantillonChoices' => array()]); }
/** * {@inheritdoc} */ public function configureAttributes(OptionsResolverInterface $resolver) { $resolver->setRequired(['tip', 'direction']); $resolver->setDefaults(['direction' => self::DOWN]); $resolver->setOptional(['name', 'short_tip', 'retractable', 'default_state', 'property_path', 'transformer']); $resolver->setDefaults(['name' => '', 'transformer' => null, 'property_path' => null, 'retractable' => function (Options $options) { return isset($options['short_tip']) && strlen($options['short_tip']); }]); $resolver->setAllowedValues(array('direction' => [self::UP, self::DOWN], 'default_state' => [self::EXPANDED, self::RETRACTED])); $resolver->setAllowedTypes(['tip' => 'string', 'direction' => 'string', 'short_tip' => 'string', 'retractable' => 'bool', 'default_state' => 'string']); }
public function setDefaultOptions(OptionsResolverInterface $resolver) { $data = array(); //Dans le cas de la modification $utilisateur envoyé en paramétre pour récupérer les roles, tous le reste est mappé automatiquement if (!empty($this->utilisateur)) { //Récupération des roles cochés sous forme de tableau compatible avec le paramétre dans de setDefaults foreach ($this->utilisateur->getRoles() as $roleValue) { array_push($data, $roleValue->getRole()); } $resolver->setDefaults(array('choices' => array('ROLE_USER' => 'Utilisateur', 'ROLE_ADMIN' => 'Administrateur', 'ROLE_SUPER_ADMIN' => 'Super administrateur'), 'multiple' => true, 'expanded' => true, 'label' => 'Profils', 'required' => true, 'data' => $data)); } else { $resolver->setDefaults(array('choices' => array('ROLE_USER' => 'Utilisateur', 'ROLE_ADMIN' => 'Administrateur', 'ROLE_SUPER_ADMIN' => 'Super administrateur'), 'multiple' => true, 'required' => true, 'expanded' => true)); } }
function it_should_configure_the_resolver(OptionsResolverInterface $resolver) { $resolver->setDefaults(array('format' => Argument::any(), 'language' => \Locale::getDefault(), 'leading_zero' => false))->shouldBeCalled(); $resolver->setOptional(array('placeholder', 'language', 'leading_zero'))->shouldBeCalled(); $resolver->setAllowedTypes(array('placeholder' => array('string'), 'language' => array('string'), 'leading_zero' => array('bool')))->shouldBeCalled(); $this->setDefaultOptions($resolver); }
/** * {@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); }]); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array('data_class' => 'Barbon\\HostedApi\\AppBundle\\Form\\Common\\Model\\BankAccount', 'validation_groups' => function (FormInterface $form) { $validationGroup = new BankAccountValidationGroupSelector(); return $validationGroup->chooseGroups($form); })); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $emptyData = function (FormInterface $form, $clientData) { return $clientData; }; $resolver->setDefaults(array('value' => '1', 'empty_data' => $emptyData, 'compound' => false)); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $class = get_class($this); $class = substr($class, strlen('Kaikmedia\\GalleryModule\\Form\\Features\\')); $class = substr($class, 0, -strlen('Type')); $resolver->setDefaults(['data_class' => 'Kaikmedia\\GalleryModule\\Features\\' . $class]); }
/** * {@inheritdoc} */ public function configureAttributes(OptionsResolverInterface $resolver) { $resolver->setRequired(['name', 'label']); $resolver->setOptional(['rows', 'comment', 'suffix', 'prefix', 'selector', 'wrap', 'class', 'css_attribute', 'max_length', 'error', 'rules', 'filters', 'dependencies', 'default', 'property_path', 'transformer']); $resolver->setDefaults(['dependencies' => [], 'filters' => [], 'rules' => [], 'transformer' => null, 'property_path' => null]); $resolver->setAllowedTypes(['name' => 'string', 'rows' => 'int', 'label' => 'string', 'comment' => 'string', 'suffix' => 'string', 'prefix' => 'string', 'selector' => 'string', 'wrap' => 'string', 'class' => 'string', 'css_attribute' => 'string', 'max_length' => 'integer', 'error' => 'string', 'filters' => 'array', 'rules' => 'array', 'dependencies' => 'array', 'default' => ['string', 'integer']]); }
/** * {@inheritDoc} */ public function setOptions(OptionsResolverInterface $resolver) { $resolver->setRequired(['forced', 'origin', 'feed', 'date_locale', 'number_locale', 'default_values']); $resolver->setAllowedValues(['date_locale' => ['en', 'nl'], 'number_locale' => ['en', 'nl']]); $resolver->setAllowedTypes(['forced' => 'bool', 'origin' => 'FM\\IoBundle\\Model\\OriginInterface', 'feed' => 'FM\\IoBundle\\Entity\\Feed', 'default_values' => 'array']); $resolver->setDefaults(['forced' => false, 'date_locale' => 'en', 'number_locale' => 'en', 'default_values' => []]); }
/** * @see Symfony\Component\Form\AbstractType::setDefaultOptions() */ public function setDefaultOptions(OptionsResolverInterface $resolver) { /* Note: the form's intention must correspond to that for the form login * listener in order for the CSRF token to validate successfully. */ $resolver->setDefaults(array('intention' => 'authenticate')); }
/** * {@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; }]); }
public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array('data_class' => 'Matthias\\User\\App\\Command\\RegisterUserCommand', 'empty_data' => function (FormInterface $form) { $command = new RegisterUserCommand($form->get('username')->getData(), $form->get('password')->getData()); return $command; })); }
/** * {@inheritdoc} */ public function configureAttributes(OptionsResolverInterface $resolver) { $resolver->setRequired(['name', 'label', 'property_path']); $resolver->setOptional(['class', 'error', 'comment', 'default', 'filters', 'rules', 'transformer']); $resolver->setDefaults(['dependencies' => [], 'filters' => [], 'rules' => [], 'property_path' => null, 'transformer' => null]); $resolver->setAllowedTypes(['name' => 'string', 'label' => 'string', 'class' => 'string', 'error' => 'string', 'comment' => 'string', 'default' => ['string', 'integer'], 'property_path' => ['null', 'object'], 'transformer' => ['null', 'object']]); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setRequired(['bundle', 'level']); $resolver->setDefaults(['multiple' => true, 'expanded' => true, 'label_attr' => ['class' => 'control-label'], 'attr' => function (Options $options) { return ['data-permission' => $options['bundle'] . ':' . $options['level'], 'onchange' => 'Mautic.onPermissionChange(this, \'' . $options['bundle'] . '\')']; }]); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $defaults = array('pickDate' => 'true', 'pickTime' => 'false', 'useMinutes' => 'false', 'useSeconds' => 'false', 'useCurrent' => 'true', 'minuteStepping' => '1', 'minDate' => '1/1/1900', 'maxDate' => '""', 'showToday' => 'false', 'language' => 'en', 'defaultDate' => '""', 'disabledDates' => '[]', 'enabledDates' => '[]', 'useStrict' => 'false', 'sideBySide' => 'false', 'daysOfWeekDisabled' => '[]', 'dateFormat' => 'YYYY-MM-DD', 'filter' => false); $resolver->setDefaults(array('widget' => 'single_text', 'Zk2DateTimeSetting' => $defaults))->setNormalizers(array('Zk2DateTimeSetting' => function (Options $options, $configs) use($defaults) { return array_merge($defaults, $configs); })); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $choiceList = function (Options $options) { return new ObjectChoiceList($options['option']->getValues(), 'value', array(), null, 'id', PropertyAccess::createPropertyAccessor()); }; $resolver->setDefaults(array('choice_list' => $choiceList))->setRequired(array('option'))->addAllowedTypes(array('option' => 'Sylius\\Component\\Variation\\Model\\OptionInterface')); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $that = $this; $resolver->setDefaults(array('category' => null, 'choice_list' => function (Options $opts, $previousValue) use($that) { return new SimpleChoiceList($that->getChoices($opts)); })); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { set_error_handler(array('Symfony\\Component\\Form\\Test\\DeprecationErrorHandler', 'handleBC')); $resolver->setDefaults($this->getDefaultOptions(array())); $resolver->addAllowedValues($this->getAllowedOptionValues(array())); restore_error_handler(); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $contexts = $this->contexts; $manager = $this->manager; $resolver->setDefaults(array('context' => false, 'multiple' => false, 'expanded' => false, 'choices' => function (Options $options, $previousValue) use($contexts, $manager) { if (!isset($contexts[$options['context']])) { if (Kernel::MINOR_VERSION < 3) { throw new \RuntimeException(sprintf('Invalid context: `%s`', $options['context'])); } throw new InvalidArgumentException(sprintf('Invalid context: `%s`', $options['context'])); } $types = array(); foreach ($contexts[$options['context']] as $service) { $types[$service] = sprintf('%s - %s', $manager->getService($service)->getName(), $service); } return $types; }, 'preferred_choices' => array(), 'empty_data' => function (Options $options) { $multiple = isset($options['multiple']) && $options['multiple']; $expanded = isset($options['expanded']) && $options['expanded']; return $multiple || $expanded ? array() : ''; }, 'empty_value' => function (Options $options, $previousValue) { $multiple = isset($options['multiple']) && $options['multiple']; $expanded = isset($options['expanded']) && $options['expanded']; return $multiple || $expanded || !isset($previousValue) ? null : ''; }, 'error_bubbling' => false)); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $that = $this; $resolver->setDefaults(array('page' => null, 'site' => null, 'choice_list' => function (Options $opts, $previousValue) use($that) { return new SimpleChoiceList($that->getChoices($opts)); }, 'filter_choice' => array('current_page' => false, 'request_method' => 'GET', 'dynamic' => true, 'hierarchy' => 'all'))); }
/** * {@inheritdoc} */ public function configureAttributes(OptionsResolverInterface $resolver) { $resolver->setRequired(['name', 'label']); $resolver->setOptional(['options', 'comment', 'suffix', 'prefix', 'error', 'selector', 'css_attribute', 'addable', 'onAdd', 'add_item_prompt', 'default', 'property_path', 'dependencies', 'filters', 'rules', 'transformer']); $resolver->setDefaults(['options' => [], 'dependencies' => [], 'filters' => [], 'rules' => [], 'property_path' => null, 'transformer' => null]); $resolver->setAllowedTypes(['name' => 'string', 'label' => 'string', 'options' => 'array', 'comment' => 'string', 'suffix' => 'string', 'prefix' => 'string', 'error' => 'string', 'selector' => 'string', 'css_attribute' => 'string', 'addable' => 'bool', 'onAdd' => 'string', 'add_item_prompt' => 'string', 'default' => ['string', 'integer'], 'rules' => 'array', 'dependencies' => 'array', 'property_path' => ['null', 'object'], 'transformer' => ['null', 'object']]); }
public function setDefaultOptions(OptionsResolverInterface $resolver) { $choiceList = function (Options $options) { return new ModelChoiceList($options['class'], $options['property'], $options['choices'], $options['query'], $options['group_by'], $options['preferred_choices']); }; $resolver->setDefaults(array('template' => 'choice', 'multiple' => false, 'expanded' => false, 'class' => null, 'property' => null, 'query' => null, 'choices' => null, 'choice_list' => $choiceList, 'group_by' => null, 'by_reference' => false)); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $self = $this; $resolver->setDefaults(array('choice_list' => function (Options $options) use($self) { return $self->getChoiceList($options['restrict']); }, 'restrict' => array())); }