function it_should_define_assigned_data_class(OptionsResolver $resolver) { $resolver->setDefaults(array('data_class' => 'Action', 'validation_groups' => array('sylius')))->shouldBeCalled(); $resolver->setDefined(array('configuration_type'))->shouldBeCalled(); $resolver->setDefaults(array('configuration_type' => ActionInterface::TYPE_FIXED_DISCOUNT))->shouldBeCalled(); $this->configureOptions($resolver); }
/** * @param OptionsResolver $resolver */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array('format' => 'MM/dd/yyyy', 'html5' => false, 'widget' => 'single_text', 'attr' => array('class' => 'date'))); if ($this->locale == 'fr') { $resolver->setDefaults(array('format' => 'dd/MM/yyyy')); } }
public function __construct() { $this->resolver = new OptionsResolver(); $this->resolver->setDefaults(['size' => 80, 'default' => 'retro', 'rating' => 'g'])->setAllowedTypes('size', 'integer')->setAllowedTypes('default', 'string')->setAllowedTypes('rating', 'string')->setAllowedValues('size', function ($value) { return $value >= 1 && $value <= 2048; })->setAllowedValues('rating', ['g', 'pg', 'r', 'x']); }
public function __construct(array $defaultParameters = array()) { $this->parametersResolver = new SymfonyResolver(); $this->parametersResolver->setDefaults(array_merge(array('currentPage' => 0, 'itemsPerPage' => 10), $defaultParameters))->setAllowedTypes('currentPage', 'int')->setAllowedTypes('itemsPerPage', 'int'); $this->filtersResolver = new SymfonyResolver(); $this->filtersResolver->setDefined(array('operator', 'value', 'sort'))->setDefaults(array('sort_priority' => 0, 'parsed' => false, 'sorted' => false))->setAllowedValues('sort', array(null, 'asc', 'desc'))->setAllowedValues('operator', array_merge(array(null), Operations::getTextOperators(), Operations::getChoiceOperators(), Operations::getDateTimeOperators()))->setAllowedTypes('sort_priority', 'int'); }
/** * 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')); }
/** * consume. * * @param array $options Parameters sent to the processor */ 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_has_author_in_configuration(OptionsResolver $resolver) { $resolver->setDefaults(['data_class' => 'ProductReview', 'validation_groups' => ['sylius']])->shouldBeCalled(); $resolver->setDefaults(['rating_steps' => 5, 'cascade_validation' => true])->shouldBeCalled(); $resolver->setDefaults(['author' => null])->shouldBeCalled(); $this->configureOptions($resolver); }
function it_should_define_assigned_data_class(OptionsResolver $resolver) { $resolver->setDefaults(['data_class' => 'Rule', 'validation_groups' => ['Default']])->shouldBeCalled(); $resolver->setDefined(['configuration_type'])->shouldBeCalled(); $resolver->setDefaults(['configuration_type' => RuleInterface::TYPE_ITEM_TOTAL])->shouldBeCalled(); $this->configureOptions($resolver); }
function it_defines_an_assigned_data_class(OptionsResolver $resolver) { $resolver->setDefaults(['data_class' => 'PromotionRule', 'validation_groups' => ['Default']])->shouldBeCalled(); $resolver->setDefined(['configuration_type'])->shouldBeCalled(); $resolver->setDefaults(['configuration_type' => ItemTotalRuleChecker::TYPE])->shouldBeCalled(); $this->configureOptions($resolver); }
public function __construct(\Doctrine\ORM\EntityManager $em, \Doctrine\ORM\Mapping\ClassMetadata $class) { $this->resolverGetEleves = new OptionsResolver(); $this->resolverGetEleves->setDefined(array('school_id', 'date_day', 'activity_type')); $this->resolverGetEleves->setAllowedTypes('date_day', \DateTimeInterface::class); $this->resolverGetEleves->setDefaults(array('school_id' => 0)); parent::__construct($em, $class); }
/** * @param DatabaseMenuProvider $provider * @param DatabaseMenuFactory $factory * @param Helper $helper * @param string $template */ public function __construct(DatabaseMenuProvider $provider, DatabaseMenuFactory $factory, Helper $helper, $template) { $this->provider = $provider; $this->factory = $factory; $this->helper = $helper; $this->resolver = new OptionsResolver(); $this->resolver->setDefaults(['depth' => 1, 'style' => 'tabs', 'template' => $template]); $this->generator = new UuidGenerator(); }
public function configureOptions(OptionsResolver $resolver) { $choices = []; try { $lists = $this->client->getLists(); foreach ($lists['data'] as $list) { $choices[$list['id']] = $list['name']; } $resolver->setDefaults(['choices' => $choices]); } catch (\Exception $e) { $resolver->setDefaults(['disabled' => true, 'help_block' => 'Invalid API Key, cannot choose a list.']); } }
private function setDefaults() { $this->resolver->setDefaults($this->defaults); $this->resolver->setDefaults([CO::VISIBILITY_LEVELS => function (Options $options) { return $this->getAccessLevelForReflections($options[CO::ACCESS_LEVELS]); }, CO::TEMPLATE => function (Options $options) { if (!$options[CO::TEMPLATE_CONFIG]) { $config = $this->getTemplateConfigPathFromTheme($options[CO::TEMPLATE_THEME]); } else { $config = $options[CO::TEMPLATE_CONFIG]; } return $this->themeConfigFactory->create($config)->getOptions(); }]); }
/** * Construct method * * @param GearmanCacheWrapper $gearmanCacheWrapper GearmanCacheWrapper * @param array $defaultSettings The default settings for the bundle */ public function __construct(GearmanCacheWrapper $gearmanCacheWrapper, array $defaultSettings) { parent::__construct($gearmanCacheWrapper, $defaultSettings); $this->executeOptionsResolver = new OptionsResolver(); $this->executeOptionsResolver->setDefaults(array('iterations' => null, 'minimum_execution_time' => null, 'timeout' => null))->setAllowedTypes('iterations', array('null', 'scalar'))->setAllowedTypes('minimum_execution_time', array('null', 'scalar'))->setAllowedTypes('timeout', array('null', 'scalar')); $this->stopWorkSignalReceived = false; /** * If the pcntl_signal exists, subscribe to the terminate and restart events for graceful worker stops. */ if (false !== function_exists('pcntl_signal')) { declare (ticks=1); pcntl_signal(SIGTERM, array($this, "handleSystemSignal")); pcntl_signal(SIGHUP, array($this, "handleSystemSignal")); } }
/** * @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 configureOptions(OptionsResolver $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 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) { $choiceList = function (Options $options) { return new VariantChoiceList($options['variable']); }; $resolver->setDefaults(['multiple' => false, 'expanded' => true, 'choice_list' => $choiceList])->setRequired(['variable'])->setAllowedTypes('variable', VariableInterface::class); }
/** * @param OptionsResolver $resolver */ public function configureOptions(OptionsResolver $resolver) { $user = $this->tokenStorage->getToken()->getUser(); $resolver->setDefaults(array('data_class' => Task::class, 'empty_data' => function (FormInterface $form) use($user) { return new Task($form->getData()['name'], $user); })); }
public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array('choices' => array('Sin confirmar' => 0, 'Confirmado' => 10, 'Cotejado' => 20, 'Certificado' => 30), 'label' => 'Nivel de confirmación', 'attr' => array('help' => '<a href="#" class="text-warning" data-toggle="collapse" data-target="#VerificacionNivelType_MasInfo"><i class="fa fa-info-circle"> </i> Más información sobre los niveles de confirmación</a> <div id="VerificacionNivelType_MasInfo" class="collapse"> <small><dl class="dl-horizontal"> <dt>Sin confirmar</dt> <dd>Datos proporcionados por la persona, por lo general de forma verbal, sobre los cuales no se tiene ninguna confirmación ni se cotejaron con alguna documentación.</dd> <dt>Confirmado</dt> <dd>Datos sobre los cuales se tiene alguna confirmación aunque sea informal. Por ejemplo: un número telefónico con el cual Usted se pudo comunicar al menos una vez.</dd> <dt>Cotejado</dt> <dd>Datos cotejados con alguna documentación pertinente, por ejemplo: la persona mostró su DNI o dejó una copia para poder cotejar el domicilio.</dd> <dt>Certificado</dt> <dd>Datos avalados por alguna prueba y sobre los cuales se conserva algún registro (original, fotocopia legalizada, fotocopia certificada, etc.).</dd> </dl></small> </div>'))); }
function getTrackingAssignments($client, array $options) { $resolver = new OptionsResolver(); $resolver->setDefaults(['project' => null, 'memberCode' => null, 'surveyCode' => null, 'date' => null]); $options = $resolver->resolve($options); $resource = new \Survos\Client\Resource\AssignmentResource($client, $params = []); $filter = []; // $filter = ['score' => 0]; $comparison = ['score' => \Survos\Client\SurvosCriteria::GREATER_THAN]; $params = ['task_type_code' => 'device']; if ($project = $options['project']) { $params['project_code'] = $project; } if ($memberCode = $options['memberCode']) { $params['member_code'] = $memberCode; } if ($surveyCode = $options['surveyCode']) { $params['survey_code'] = $surveyCode; } if ($date = $options['date']) { $filter['scheduled_time'] = $date; $filter['scheduled_end_time'] = $date; $comparison['scheduled_time'] = \Survos\Client\SurvosCriteria::LESS_EQUAL; $comparison['scheduled_end_time'] = \Survos\Client\SurvosCriteria::GREATER_EQUAL; } return $resource->getList(null, null, $filter = [], $comparison, null, $params); }
/** * {@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')); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolver $resolver) { $resolver->setRequired(['new_relic_app_name']); $resolver->setDefaults(['new_relic_license' => null, 'new_relic_transaction_name' => function (Options $options) { return sprintf('swarrot %s', $options['queue']); }]); }
/** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array('expanded' => true)); $resolver->setNormalizer('choices', function () { return array('attr1' => 'Attribute 1', 'attr2' => 'Attribute 2'); }); }
public function testSetDefaults() { $this->resolver->setDefault('one', '1'); $this->resolver->setDefault('two', 'bar'); $this->resolver->setDefaults(array('two' => '2', 'three' => '3')); $this->assertEquals(array('one' => '1', 'two' => '2', 'three' => '3'), $this->resolver->resolve()); }
/** * {@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); } return $value; }; $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('type', $typeNormalizer); $resolver->setNormalizer('options', $optionsNormalizer); $resolver->setNormalizer('entry_options', $entryOptionsNormalizer); }
/** * {@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']); }
public function configureOptions(OptionsResolver $resolver) { $resolver->setRequired(['roles']); $resolver->setDefaults(['csrf_protection' => false, 'data_class' => InviteUserCommand::class, 'empty_data' => function (FormInterface $form) { return new InviteUserCommand($form->get('email')->getData(), $this->roles); }]); }
public function testNotRequiredIfRequiredAndDefaultValue() { $this->assertFalse($this->resolver->isRequired('foo')); $this->resolver->setRequired(array('foo')); $this->resolver->setDefaults(array('foo' => 'bar')); $this->assertFalse($this->resolver->isRequired('foo')); }
/** * {@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'); }