/**
  * @return OptionsResolverInterface
  */
 protected function createOptionsResolver()
 {
     $resolver = new OptionsResolver();
     $resolver->setOptional(['flush', 'copy_values_to_products', 'add_products', 'remove_products']);
     $resolver->setAllowedTypes(['flush' => 'bool', 'copy_values_to_products' => 'bool', 'add_products' => 'array', 'remove_products' => 'array']);
     return $resolver;
 }
Beispiel #2
0
 /**
  * {@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}
  */
 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']);
 }
Beispiel #4
0
 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);
 }
 /**
  * {@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('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');
 }
Beispiel #7
0
 /**
  * @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);
     }));
 }
 /**
  * When creating this subscriber, you can configure a number of options.
  *
  * - refresh_client_matcher: RequestMatcher to identify valid refresh clients.
  * - refresh_client_ips:     IP or array of IPs that are allowed to refresh.
  *
  * Only set one of refresh_client_ips and refresh_client_matcher.
  *
  * @param array $options Options to overwrite the default options
  *
  * @throws \InvalidArgumentException if unknown keys are found in $options
  */
 public function __construct(array $options = [])
 {
     $resolver = new OptionsResolver();
     $resolver->setDefaults(['refresh_client_matcher' => null, 'refresh_client_ips' => null]);
     $options = $resolver->resolve($options);
     parent::__construct($options['refresh_client_matcher'], $options['refresh_client_ips']);
 }
Beispiel #9
0
 /**
  * Resolve amount option
  *
  * @param OptionsResolver $resolver
  */
 protected function setCurrencyResolver(OptionsResolver $resolver)
 {
     $resolver->setAllowedTypes('currency', ['string', 'int']);
     $resolver->setAllowedValues('currency', function ($value) {
         return CurrencyTypes::currencyCodeExists($value) || CurrencyTypes::currencyNumberExists($value);
     });
 }
Beispiel #10
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']);
 }
 /**
  * @param array $options
  */
 public function __construct(array $options)
 {
     $resolver = new OptionsResolver();
     $resolver->setRequired(['secret', 'currency', 'min_sum'])->setDefaults(['math' => new NativeMath(), 'currency' => 'usd', 'min_sum' => 0])->setAllowedTypes('math', MathInterface::class);
     $options = $resolver->resolve($options);
     $this->options = $options;
 }
 /**
  * 
  * @param array $options
  * @return array
  */
 public function configureOptions(array $options = array())
 {
     $resolver = new OptionsResolver();
     $resolver->setDefaults(array('adapter' => 'default', 'host' => $this->getHost(), 'username' => null, 'password' => null, 'port' => $this->getPort(), 'auth_mode' => $this->getAuthMode(), 'encryption' => $this->getEncryption()));
     $this->options = $resolver->resolve($options);
     return $this->options;
 }
Beispiel #13
0
 /**
  * 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);
     }
 }
Beispiel #14
0
 /**
  * Resolves options
  *
  * @param array $options
  * @return array
  */
 protected function resolveConfigurationOptions(array $configurationOptions)
 {
     $optionsResolver = new OptionsResolver();
     $optionsResolver->setDefaults($this->defaultOptions);
     $optionsResolver->setRequired(array_keys($this->defaultOptions));
     return $optionsResolver->resolve($configurationOptions);
 }
Beispiel #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);
         }
         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}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var ChannelInterface $channel */
     $channel = $this->channelFactory->createNamed($options['name']);
     $channel->setCode($options['code']);
     $channel->setHostname($options['hostname']);
     $channel->setEnabled($options['enabled']);
     $channel->setColor($options['color']);
     $channel->setTaxCalculationStrategy($options['tax_calculation_strategy']);
     $channel->setThemeName($options['theme_name']);
     $channel->setDefaultLocale($options['default_locale']);
     foreach ($options['locales'] as $locale) {
         $channel->addLocale($locale);
     }
     $channel->setDefaultCurrency($options['default_currency']);
     foreach ($options['currencies'] as $currency) {
         $channel->addCurrency($currency);
     }
     foreach ($options['payment_methods'] as $paymentMethod) {
         $channel->addPaymentMethod($paymentMethod);
     }
     foreach ($options['shipping_methods'] as $shippingMethod) {
         $channel->addShippingMethod($shippingMethod);
     }
     return $channel;
 }
Beispiel #17
0
 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);
     }]);
 }
Beispiel #18
0
 /**
  * @return OptionsResolver
  */
 public function getConfigurableOptions()
 {
     $resolver = new OptionsResolver();
     $resolver->setDefaults(['ignore_patterns' => []]);
     $resolver->addAllowedTypes('ignore_patterns', ['array']);
     return $resolver;
 }
 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>')));
 }
 /**
  * @param OptionsResolver $resolver
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $multiLanguagesChoiceManager = $this->multiLanguagesChoiceManager;
     $resolver->setDefaults(array('embedded' => true, 'class' => $this->statusClass, 'choice_label' => function (StatusInterface $choice) use($multiLanguagesChoiceManager) {
         return $multiLanguagesChoiceManager->choose($choice->getLabels());
     }));
 }
Beispiel #21
0
 /**
  * {@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);
 }
    /**
     * {@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);
    }
Beispiel #23
0
 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}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $registry = $this->registry;
     $resolver->setDefaults(array('em' => null, 'class' => null, 'property' => null, 'query_builder' => null, 'choices' => null, 'group_by' => null, 'ajax' => false, 'choice_list' => function (Options $options, $previousValue) use($registry) {
         return new AjaxEntityChoiceList($options['em'], $options['class'], $options['property'], $options['query_builder'], $options['choices'], $options['group_by'], $options['ajax']);
     }));
 }
Beispiel #25
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'));
 }
Beispiel #26
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('expanded' => true));
     $resolver->setNormalizer('choices', function () {
         return array('attr1' => 'Attribute 1', 'attr2' => 'Attribute 2');
     });
 }
Beispiel #27
0
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['sonata_field_description', 'context'])->setAllowedTypes('sonata_field_description', 'Sonata\\DoctrineORMAdminBundle\\Admin\\FieldDescription')->setDefaults(['attr' => ['class' => 'select2'], 'multiple' => true, 'required' => false])->setDefault('create_callback', function (Options $options) {
         /**
          * @var \Sonata\DoctrineORMAdminBundle\Admin\FieldDescription
          */
         $fieldDescription = $options['sonata_field_description'];
         $class = $fieldDescription->getTargetEntity();
         return function ($name, $context) use($class) {
             $tag = new $class();
             $tag->setName($name);
             $tag->setEnabled(true);
             if ($context) {
                 $tag->setContext($context);
             }
             return $tag;
         };
     })->setDefault('tags', function (Options $options) {
         /**
          * @var \Sonata\DoctrineORMAdminBundle\Admin\FieldDescription
          */
         $fieldDescription = $options['sonata_field_description'];
         return $fieldDescription->getAdmin()->getModelManager()->findBy($fieldDescription->getTargetEntity(), ['enabled' => true, 'context' => $options['context']]);
     });
 }
Beispiel #28
0
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefined(['customFormModel', 'territoryRepository', 'projectSettings']);
     $resolver->setRequired(['customFormModel', 'territoryRepository', 'projectSettings']);
     $resolver->addAllowedTypes('customFormModel', CustomFormModelInterface::class);
     $resolver->addAllowedTypes('projectSettings', ProjectSettings::class);
 }
 /**
  * @return OptionsResolverInterface
  */
 protected function createOptionsResolver()
 {
     $resolver = new OptionsResolver();
     $resolver->setOptional(['flush', 'schedule']);
     $resolver->setAllowedTypes(['flush' => 'bool', 'schedule' => 'bool']);
     return $resolver;
 }
 public function testChoiceNormalizer()
 {
     // source data
     $workflowAwareClass = 'WorkflowAwareClass';
     $extendedClass = 'ExtendedClass';
     $notExtendedClass = 'NotExtendedClass';
     $notConfigurableClass = 'NotConfigurableClass';
     // asserts
     $this->entityConnector->expects($this->any())->method('isWorkflowAware')->will($this->returnCallback(function ($class) use($workflowAwareClass) {
         return $class === $workflowAwareClass;
     }));
     $extendedEntityConfig = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
     $extendedEntityConfig->expects($this->any())->method('is')->with('is_extend')->will($this->returnValue(true));
     $notExtendedEntityConfig = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
     $notExtendedEntityConfig->expects($this->any())->method('is')->with('is_extend')->will($this->returnValue(false));
     $extendConfigProvider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock();
     $hasConfigMap = array(array($workflowAwareClass, null, false), array($extendedClass, null, true), array($notExtendedClass, null, true), array($notConfigurableClass, null, false));
     $extendConfigProvider->expects($this->any())->method('hasConfig')->with($this->isType('string'), null)->will($this->returnValueMap($hasConfigMap));
     $getConfigMap = array(array($extendedClass, null, $extendedEntityConfig), array($notExtendedClass, null, $notExtendedEntityConfig));
     $extendConfigProvider->expects($this->any())->method('getConfig')->with($this->isType('string'), null)->will($this->returnValueMap($getConfigMap));
     $this->configManager->expects($this->once())->method('getProvider')->with('extend')->will($this->returnValue($extendConfigProvider));
     // test
     $inputChoices = array($workflowAwareClass => Inflector::tableize($workflowAwareClass), $extendedClass => Inflector::tableize($extendedClass), $notExtendedClass => Inflector::tableize($notExtendedClass), $notConfigurableClass => Inflector::tableize($notConfigurableClass));
     $expectedChoices = array($workflowAwareClass => Inflector::tableize($workflowAwareClass), $extendedClass => Inflector::tableize($extendedClass));
     $resolver = new OptionsResolver();
     $resolver->setDefaults(array('choices' => $inputChoices));
     $this->formType->setDefaultOptions($resolver);
     $result = $resolver->resolve(array());
     $this->assertEquals($expectedChoices, $result['choices']);
 }