當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。