本文整理汇总了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);
}
示例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'));
}
}
示例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']);
}
示例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');
}
示例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'));
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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.']);
}
}
示例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();
}]);
}
示例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"));
}
}
示例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);
}