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


PHP OptionsResolverInterface::setDefaults方法代码示例

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


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

示例1: array

 function it_should_define_assigned_data_class(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('data_class' => 'Rule', 'validation_groups' => array('sylius')))->shouldBeCalled();
     $resolver->setOptional(array('configuration_type'))->shouldBeCalled();
     $resolver->setDefaults(array('configuration_type' => RuleInterface::TYPE_ITEM_TOTAL))->shouldBeCalled();
     $this->setDefaultOptions($resolver);
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:7,代码来源:RuleTypeSpec.php

示例2: __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,
             'exclude_from' => array(),
             'exclude_to'   => array(),
         )
     );
     $this->specResolver->setAllowedTypes(
         array(
             'on'           => array('string', 'array'),
             'from'         => array('string', 'array'),
             'to'           => array('string', 'array'),
             'exclude_from' => array('string', 'array'),
             'exclude_to'   => array('string', 'array'),
         )
     );
     $toArrayNormalizer = function (Options $options, $value) {
         return (array)$value;
     };
     $this->specResolver->setNormalizers(
         array(
             'on'           => $toArrayNormalizer,
             'from'         => $toArrayNormalizer,
             'to'           => $toArrayNormalizer,
             'exclude_to'   => $toArrayNormalizer,
             'exclude_from' => $toArrayNormalizer,
         )
     );
 }
开发者ID:Aasit,项目名称:DISCOUNT--SRV-I,代码行数:38,代码来源:CallbackHandler.php

示例3: consume

 /**
  * consume
  *
  * @param array $options Parameters sent to the processor
  *
  * @return void
  */
 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:Niktux,项目名称:swarrot,代码行数:37,代码来源:Consumer.php

示例4: array

 function it_should_define_assigned_data_class(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('data_class' => 'Action', 'validation_groups' => array('sylius')))->shouldBeCalled();
     $resolver->setOptional(array('configuration_type'))->shouldBeCalled();
     $resolver->setDefaults(array('configuration_type' => ActionInterface::TYPE_FIXED_DISCOUNT))->shouldBeCalled();
     $this->setDefaultOptions($resolver);
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:7,代码来源:ActionTypeSpec.php

示例5: setDefaultOptions

 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     if ($this->routeName != "miw_rest_user_newuser") {
         $resolver->setDefaults(array('data_class' => $this->class, 'intention' => 'registration'));
     } else {
         $resolver->setDefaults(array('data_class' => $this->class, 'intention' => 'registration', 'csrf_protection' => false));
     }
 }
开发者ID:carlos-mora,项目名称:pfmweb,代码行数:8,代码来源:RestRegistrationFormType.php

示例6: setDefaultOptions

 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     if ($this->editMode) {
         $resolver->setDefaults(array('class' => 'FormaLibre\\ReservationBundle\\Entity\\Reservation', 'translation_domain' => 'reservation', 'constraints' => new ReservationModify()));
     } else {
         $resolver->setDefaults(array('class' => 'FormaLibre\\ReservationBundle\\Entity\\Reservation', 'translation_domain' => 'reservation', 'constraints' => new Reservation()));
     }
 }
开发者ID:GauthLin,项目名称:ReservationBundle,代码行数:8,代码来源:ReservationType.php

示例7: setDefaultOptions

 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['praticiensChoices']);
     $resolver->setDefaults(['praticiensChoices' => array()]);
     $resolver->setRequired(['motifChoices']);
     $resolver->setDefaults(['motifChoices' => array()]);
     $resolver->setRequired(['echantillonChoices']);
     $resolver->setDefaults(['echantillonChoices' => array()]);
 }
开发者ID:CorentinDodon,项目名称:GSB-PHP,代码行数:9,代码来源:SaisieType.php

示例8: configureAttributes

 /**
  * {@inheritdoc}
  */
 public function configureAttributes(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['tip', 'direction']);
     $resolver->setDefaults(['direction' => self::DOWN]);
     $resolver->setOptional(['name', 'short_tip', 'retractable', 'default_state', 'property_path', 'transformer']);
     $resolver->setDefaults(['name' => '', 'transformer' => null, 'property_path' => null, 'retractable' => function (Options $options) {
         return isset($options['short_tip']) && strlen($options['short_tip']);
     }]);
     $resolver->setAllowedValues(array('direction' => [self::UP, self::DOWN], 'default_state' => [self::EXPANDED, self::RETRACTED]));
     $resolver->setAllowedTypes(['tip' => 'string', 'direction' => 'string', 'short_tip' => 'string', 'retractable' => 'bool', 'default_state' => 'string']);
 }
开发者ID:jmarceli,项目名称:WellCommerce,代码行数:14,代码来源:Tip.php

示例9: setDefaultOptions

 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $data = array();
     //Dans le cas de la modification $utilisateur envoyé en paramétre pour récupérer les roles, tous le reste est mappé automatiquement
     if (!empty($this->utilisateur)) {
         //Récupération des roles cochés sous forme de tableau compatible avec le paramétre dans de setDefaults
         foreach ($this->utilisateur->getRoles() as $roleValue) {
             array_push($data, $roleValue->getRole());
         }
         $resolver->setDefaults(array('choices' => array('ROLE_USER' => 'Utilisateur', 'ROLE_ADMIN' => 'Administrateur', 'ROLE_SUPER_ADMIN' => 'Super administrateur'), 'multiple' => true, 'expanded' => true, 'label' => 'Profils', 'required' => true, 'data' => $data));
     } else {
         $resolver->setDefaults(array('choices' => array('ROLE_USER' => 'Utilisateur', 'ROLE_ADMIN' => 'Administrateur', 'ROLE_SUPER_ADMIN' => 'Super administrateur'), 'multiple' => true, 'required' => true, 'expanded' => true));
     }
 }
开发者ID:ramisg85,项目名称:oueslatirami,代码行数:14,代码来源:RoleType.php

示例10: array

 function it_should_configure_the_resolver(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('format' => Argument::any(), 'language' => \Locale::getDefault(), 'leading_zero' => false))->shouldBeCalled();
     $resolver->setOptional(array('placeholder', 'language', 'leading_zero'))->shouldBeCalled();
     $resolver->setAllowedTypes(array('placeholder' => array('string'), 'language' => array('string'), 'leading_zero' => array('bool')))->shouldBeCalled();
     $this->setDefaultOptions($resolver);
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:7,代码来源:DateExtensionSpec.php

示例11: setDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $defaultFieldOptions = ['multiple' => true];
     $resolver->setDefaults(['dictionary_code' => null, 'class' => null, 'field_options' => $defaultFieldOptions]);
     $resolver->setNormalizers(['class' => function (Options $options, $value) {
         if ($value !== null) {
             return $value;
         }
         if (empty($options['dictionary_code'])) {
             throw new InvalidOptionsException('Either "class" or "dictionary_code" must option must be set.');
         }
         $class = ExtendHelper::buildEnumValueClassName($options['dictionary_code']);
         if (!is_a($class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue', true)) {
             throw new InvalidOptionsException(sprintf('"%s" must be a child of "%s"', $class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue'));
         }
         return $class;
     }, 'field_options' => function (Options $options, $value) use(&$defaultFieldOptions) {
         if (isset($options['class'])) {
             $nullValue = null;
             if ($options->has('null_value')) {
                 $nullValue = $options->get('null_value');
             }
             $value['choices'] = $this->getChoices($options['class'], $nullValue);
         } else {
             $value['choices'] = [];
         }
         return array_merge($defaultFieldOptions, $value);
     }]);
 }
开发者ID:Maksold,项目名称:platform,代码行数:32,代码来源:DictionaryFilterType.php

示例12: setDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('data_class' => 'Barbon\\HostedApi\\AppBundle\\Form\\Common\\Model\\BankAccount', 'validation_groups' => function (FormInterface $form) {
         $validationGroup = new BankAccountValidationGroupSelector();
         return $validationGroup->chooseGroups($form);
     }));
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:10,代码来源:BankAccountType.php

示例13: setDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $emptyData = function (FormInterface $form, $clientData) {
         return $clientData;
     };
     $resolver->setDefaults(array('value' => '1', 'empty_data' => $emptyData, 'compound' => false));
 }
开发者ID:joan16v,项目名称:symfony2_test,代码行数:10,代码来源:CheckboxType.php

示例14: setDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $class = get_class($this);
     $class = substr($class, strlen('Kaikmedia\\GalleryModule\\Form\\Features\\'));
     $class = substr($class, 0, -strlen('Type'));
     $resolver->setDefaults(['data_class' => 'Kaikmedia\\GalleryModule\\Features\\' . $class]);
 }
开发者ID:Kaik,项目名称:KaikMediaGallery,代码行数:10,代码来源:AbstractFeatureType.php

示例15: configureAttributes

 /**
  * {@inheritdoc}
  */
 public function configureAttributes(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['name', 'label']);
     $resolver->setOptional(['rows', 'comment', 'suffix', 'prefix', 'selector', 'wrap', 'class', 'css_attribute', 'max_length', 'error', 'rules', 'filters', 'dependencies', 'default', 'property_path', 'transformer']);
     $resolver->setDefaults(['dependencies' => [], 'filters' => [], 'rules' => [], 'transformer' => null, 'property_path' => null]);
     $resolver->setAllowedTypes(['name' => 'string', 'rows' => 'int', 'label' => 'string', 'comment' => 'string', 'suffix' => 'string', 'prefix' => 'string', 'selector' => 'string', 'wrap' => 'string', 'class' => 'string', 'css_attribute' => 'string', 'max_length' => 'integer', 'error' => 'string', 'filters' => 'array', 'rules' => 'array', 'dependencies' => 'array', 'default' => ['string', 'integer']]);
 }
开发者ID:jmarceli,项目名称:WellCommerce,代码行数:10,代码来源:TextArea.php


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