當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OptionsResolver\OptionsResolver類代碼示例

本文整理匯總了PHP中Symfony\Component\OptionsResolver\OptionsResolver的典型用法代碼示例。如果您正苦於以下問題:PHP OptionsResolver類的具體用法?PHP OptionsResolver怎麽用?PHP OptionsResolver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了OptionsResolver類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: configureOptions

 /**
  * {@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'));
 }
開發者ID:Dren-x,項目名稱:mobit,代碼行數:10,代碼來源:UserLoginFormType.php

示例3: configureOptionResolver

 /**
  * {@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']);
 }
開發者ID:php-cache,項目名稱:adapter-bundle,代碼行數:10,代碼來源:MemcacheFactory.php

示例4:

 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

示例5: setDefaultOptions

 /**
  * {@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']);
     }]);
 }
開發者ID:behinddesign,項目名稱:swarrot,代碼行數:10,代碼來源:NewRelicProcessor.php

示例6: configureOptions

 /**
  * {@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');
 }
開發者ID:BusinessCookies,項目名稱:CoffeeMachineProject,代碼行數:10,代碼來源:RepeatedType.php

示例7: configureOptions

 /**
  * @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);
     }));
 }
開發者ID:klinki,項目名稱:timer,代碼行數:10,代碼來源:TaskType.php

示例8: __construct

 /**
  * 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']);
 }
開發者ID:heartshare,項目名稱:FOSHttpCache,代碼行數:19,代碼來源:RefreshSubscriber.php

示例9: setCurrencyResolver

 /**
  * 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);
     });
 }
開發者ID:lsv,項目名稱:altapay-php-api,代碼行數:12,代碼來源:CurrencyTrait.php

示例10: configureOptions

 /**
  * {@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']);
 }
開發者ID:rollerworks,項目名稱:datagrid,代碼行數:10,代碼來源:TextType.php

示例11: __construct

 /**
  * @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;
 }
開發者ID:moriony,項目名稱:payment-gateway,代碼行數:10,代碼來源:StripeHandler.php

示例12: configureOptions

 /**
  * 
  * @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;
 }
開發者ID:snikolow,項目名稱:silex-issue-tracker,代碼行數:12,代碼來源:AbstractMailer.php

示例13: resolveConfigurationOptions

 /**
  * 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);
 }
開發者ID:EHLOVader,項目名稱:CodeQualityThreshold,代碼行數:13,代碼來源:Tool.php

示例14: configureOptions

 /**
  * {@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);
 }
開發者ID:Kyra2778,項目名稱:AMR,代碼行數:38,代碼來源:CollectionType.php

示例15: configureOptions

 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);
     }]);
 }
開發者ID:kreta,項目名稱:kreta,代碼行數:7,代碼來源:InviteType.php


注:本文中的Symfony\Component\OptionsResolver\OptionsResolver類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。