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


PHP OptionsResolver::setOptional方法代码示例

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


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

示例1: update

 /**
  * @param ProductInterface $product
  * @param array            $updates
  *
  * @return bool
  */
 protected function update(ProductInterface $product, array $updates)
 {
     $resolver = new OptionsResolver();
     $resolver->setRequired(['type']);
     $resolver->setAllowedValues(['type' => ['set_data', 'copy_data', 'add_data', 'remove_data']]);
     $resolver->setOptional(['field', 'data', 'locale', 'scope', 'from_field', 'to_field', 'from_locale', 'to_locale', 'from_scope', 'to_scope']);
     $resolver->setDefaults(['locale' => null, 'scope' => null, 'from_locale' => null, 'to_locale' => null, 'from_scope' => null, 'to_scope' => null]);
     foreach ($updates as $update) {
         $update = $resolver->resolve($update);
         switch ($update['type']) {
             case 'set_data':
                 $this->applySetData($product, $update);
                 break;
             case 'copy_data':
                 $this->applyCopyData($product, $update);
                 break;
             case 'add_data':
                 $this->applyAddData($product, $update);
                 break;
             case 'remove_data':
                 $this->applyRemoveData($product, $update);
                 break;
         }
     }
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:31,代码来源:UpdateProductCommand.php

示例2: createOptionsResolver

 /**
  * @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;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:10,代码来源:GroupSavingOptionsResolver.php

示例3: createOptionsResolver

 /**
  * @return OptionsResolverInterface
  */
 protected function createOptionsResolver()
 {
     $resolver = new OptionsResolver();
     $resolver->setOptional(['flush', 'schedule']);
     $resolver->setAllowedTypes(['flush' => 'bool', 'schedule' => 'bool']);
     return $resolver;
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:10,代码来源:CompletenessSavingOptionsResolver.php

示例4: createOptionsResolver

 /**
  * @return OptionsResolverInterface
  */
 protected function createOptionsResolver()
 {
     $resolver = new OptionsResolver();
     $resolver->setOptional(['flush']);
     $resolver->setAllowedTypes(['flush' => 'bool']);
     $resolver->setDefaults(['flush' => true]);
     return $resolver;
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:11,代码来源:BaseSavingOptionsResolver.php

示例5: __construct

 public function __construct(array $options = [])
 {
     $resolver = new OptionsResolver();
     $resolver->setOptional($this->getOptionalOptions());
     $resolver->setAllowedTypes($this->getAllowedOptionTypes());
     $resolver->setDefaults($this->getDefaultOptions());
     $this->options = $resolver->resolve($options);
 }
开发者ID:RobinGeuze,项目名称:php-code-generator,代码行数:8,代码来源:CodeGeneratorConfig.php

示例6: getTagitOptions

 /**
  * Resolves tag-it options.
  * See {@link https://github.com/aehlke/tag-it}
  *
  * @param FormInterface $form
  */
 protected function getTagitOptions(FormInterface $form)
 {
     $resolver = new OptionsResolver();
     $resolver->setOptional(array('availableTags', 'autocomplete', 'showAutocompleteOnFocus', 'removeConfirmation', 'caseSensitive', 'allowDuplicates', 'allowSpaces', 'readOnly', 'tagLimit', 'singleField', 'singleFieldDelimiter', 'singleFieldNode', 'tabIndex', 'placeholderText'));
     $resolver->setAllowedTypes(array('autocomplete' => 'array'));
     $resolver->setDefaults(array('allowSpaces' => true, 'removeConfirmation' => true, 'singleFieldDelimiter' => ',', 'autocomplete' => array()));
     return $resolver->resolve($form->getConfig()->getOption('tagit', array()));
 }
开发者ID:sdaoudi,项目名称:AnhTaggableBundle,代码行数:14,代码来源:TagsType.php

示例7: configureOptions

 /**
  * {@inheritDoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $optionNames = array('flow_instance', 'flow_instance_key', 'flow_step', 'flow_step_key');
     if (Kernel::VERSION_ID < 20600) {
         $resolver->setOptional($optionNames);
     } else {
         $resolver->setDefined($optionNames);
     }
 }
开发者ID:raizeta,项目名称:CraueFormFlowBundle,代码行数:12,代码来源:FormFlowFormExtension.php

示例8: send

 public function send(array $config = [])
 {
     $resolver = new OptionsResolver();
     $resolver->setOptional(array_keys($config));
     $resolver->setRequired(['protocol']);
     $config = $resolver->resolve($config);
     if (false !== ($transport = $this->transportChain->getTransport($config['protocol']))) {
         return $transport->send($config);
     }
 }
开发者ID:pbh-techno,项目名称:communicator-bundle,代码行数:10,代码来源:Transport.php

示例9: loadTransitions

 /**
  * @param StateMachineInterface $stateMachine
  */
 private function loadTransitions(StateMachineInterface $stateMachine)
 {
     $resolver = new OptionsResolver();
     $resolver->setRequired(array('from', 'to'));
     $resolver->setOptional(array('guard'));
     $resolver->setNormalizers(array('from' => function (Options $options, $v) {
         return (array) $v;
     }, 'guard' => function (Options $options, $v) {
         return !isset($v) ? null : $v;
     }));
     foreach ($this->config['transitions'] as $transition => $config) {
         $config = $resolver->resolve($config);
         $stateMachine->addTransition(new Transition($transition, $config['from'], $config['to'], $config['guard']));
     }
 }
开发者ID:virasak,项目名称:Finite,代码行数:18,代码来源:ArrayLoader.php

示例10: update

 /**
  * @param ProductInterface $product
  * @param array            $updates
  *
  * @return boolean
  */
 protected function update(ProductInterface $product, array $updates)
 {
     $resolver = new OptionsResolver();
     $resolver->setRequired(['type']);
     $resolver->setAllowedValues(['type' => ['set_value', 'copy_value']]);
     $resolver->setOptional(['field', 'value', 'locale', 'scope', 'from_field', 'to_field', 'from_locale', 'to_locale', 'from_scope', 'to_scope']);
     $resolver->setDefaults(['locale' => null, 'scope' => null, 'from_locale' => null, 'to_locale' => null, 'from_scope' => null, 'to_scope' => null]);
     foreach ($updates as $update) {
         $update = $resolver->resolve($update);
         if ('set_value' === $update['type']) {
             $this->applySetValue($product, $update);
         } else {
             $this->applyCopyValue($product, $update);
         }
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:22,代码来源:UpdateProductCommand.php

示例11: configureOptions

 /**
  * Add the client_validation option
  *
  * @param OptionsResolverInterface $resolver
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setOptional(array('client_validation'));
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:9,代码来源:ClientValidationExtension.php

示例12: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setOptional(array('block', 'subblock', 'block_config', 'tooltip'));
 }
开发者ID:aml-bendall,项目名称:ExpandAkeneoApi,代码行数:7,代码来源:DataBlockExtension.php

示例13: createOptionsResolver

 /**
  * @return OptionsResolverInterface
  */
 protected function createOptionsResolver()
 {
     $resolver = new OptionsResolver();
     $required = [];
     $allowedTypes = ['family' => 'string', 'enabled' => 'bool', 'categories' => 'string', 'groups' => 'string'];
     $optional = array_merge(['family', 'enabled', 'categories', 'groups'], $this->attrColumnsResolver->resolveAttributeColumns(), $this->getOptionalAssociationFields());
     $resolver->setRequired($required);
     $resolver->setOptional($optional);
     $resolver->setAllowedTypes($allowedTypes);
     $booleanNormalizer = function ($options, $value) {
         return (bool) $value;
     };
     $resolver->setNormalizers(['enabled' => $booleanNormalizer]);
     return $resolver;
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:18,代码来源:ProductStandardConverter.php

示例14: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $queue = $input->getArgument('queue');
     $connection = $input->getArgument('connection');
     $factory = $this->getContainer()->get('swarrot.factory.default');
     $messageProvider = $factory->getMessageProvider($queue, $connection);
     $stack = new Builder();
     if (array_key_exists('signal_handler', $this->processorStack)) {
         $stack->push($this->processorStack['signal_handler'], $this->logger);
     }
     if (array_key_exists('max_messages', $this->processorStack)) {
         $stack->push($this->processorStack['max_messages'], $this->logger);
     }
     if (array_key_exists('max_execution_time', $this->processorStack)) {
         $stack->push($this->processorStack['max_execution_time'], $this->logger);
     }
     if (array_key_exists('exception_catcher', $this->processorStack) && !$input->getOption('no-catch')) {
         $stack->push($this->processorStack['exception_catcher'], $this->logger);
     }
     if (array_key_exists('ack', $this->processorStack)) {
         $stack->push($this->processorStack['ack'], $messageProvider, $this->logger);
     }
     if (array_key_exists('retry', $this->processorStack) && !$input->getOption('no-retry')) {
         $exchange = 'retry';
         if (isset($this->extras['retry_exchange'])) {
             $exchange = $this->extras['retry_exchange'];
         }
         $messagePublisher = $factory->getMessagePublisher($exchange, $connection);
         $stack->push($this->processorStack['retry'], $messagePublisher, $this->logger);
     }
     $processor = $stack->resolve($this->processor);
     $optionsResolver = new OptionsResolver();
     $optionsResolver->setOptional(array('queue', 'connection'));
     $consumer = new Consumer($messageProvider, $processor, $optionsResolver);
     $consumer->consume($this->getOptions($input));
 }
开发者ID:antoox,项目名称:SwarrotBundle,代码行数:36,代码来源:SwarrotCommand.php

示例15: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setOptional($this->optionalParameters);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:7,代码来源:TooltipFormExtension.php


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