当前位置: 首页>>代码示例>>PHP>>正文


PHP OptionsResolver::setDefaults方法代码示例

本文整理汇总了PHP中Symfony\Component\OptionsResolver\OptionsResolver::setDefaults方法的典型用法代码示例。如果您正苦于以下问题:PHP OptionsResolver::setDefaults方法的具体用法?PHP OptionsResolver::setDefaults怎么用?PHP OptionsResolver::setDefaults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\OptionsResolver\OptionsResolver的用法示例。


在下文中一共展示了OptionsResolver::setDefaults方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 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);
 }
开发者ID:lingoda,项目名称:Sylius,代码行数:7,代码来源:ActionTypeSpec.php

示例2: configureOptions

 /**
  * @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'));
     }
 }
开发者ID:thomasage,项目名称:asso,代码行数:10,代码来源:DatePickerType.php

示例3: __construct

 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']);
 }
开发者ID:Briareos,项目名称:Undine,代码行数:7,代码来源:GravatarExtension.php

示例4: __construct

 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');
 }
开发者ID:WedgeSama,项目名称:Listor,代码行数:7,代码来源:OptionsResolver.php

示例5: configureWeekMealOptions

 /**
  * 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'));
 }
开发者ID:WildCodeSchool,项目名称:projet-gesty,代码行数:13,代码来源:LunchRepository.php

示例6: consume

 /**
  * 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);
     }
 }
开发者ID:kyar,项目名称:swarrot,代码行数:35,代码来源:Consumer.php

示例7:

 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);
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:7,代码来源:ProductReviewTypeSpec.php

示例8:

 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);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:7,代码来源:RuleTypeSpec.php

示例9:

 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);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:7,代码来源:PromotionRuleTypeSpec.php

示例10: __construct

 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);
 }
开发者ID:WildCodeSchool,项目名称:projet-gesty,代码行数:8,代码来源:EleveRepository.php

示例11: __construct

 /**
  * @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();
 }
开发者ID:integratedfordevelopers,项目名称:integrated-website-bundle,代码行数:15,代码来源:MenuExtension.php

示例12: configureOptions

 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.']);
     }
 }
开发者ID:symedit,项目名称:symedit,代码行数:13,代码来源:ListType.php

示例13: setDefaults

 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();
     }]);
 }
开发者ID:nunodotferreira,项目名称:ApiGen,代码行数:14,代码来源:ConfigurationOptionsResolver.php

示例14: __construct

 /**
  * 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"));
     }
 }
开发者ID:WayOfBrave,项目名称:GearmanBundle,代码行数:21,代码来源:GearmanExecute.php

示例15: __construct

 /**
  * @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);
 }
开发者ID:Rioji,项目名称:Finite,代码行数:18,代码来源:CallbackHandler.php


注:本文中的Symfony\Component\OptionsResolver\OptionsResolver::setDefaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。