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


PHP OptionsResolver::setAllowedTypes方法代码示例

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


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

示例1: configureOptions

 /**
  * @param OptionsResolver $resolver
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['fields', 'associations', 'callbacks']);
     $fieldsNormalizer = function (Options $options, $fields) {
         $collection = new Collection\FieldMetadataCollection();
         $factory = new FieldMetadataFactory();
         foreach ($fields as $fieldName => $parameters) {
             $fieldMetadata = $factory->create($fieldName, $parameters);
             $collection->add($fieldMetadata);
         }
         return $collection;
     };
     $associationsNormalizer = function (Options $options, $associations) {
         $collection = new Collection\AssociationMetadataCollection();
         $factory = new AssociationMetadataFactory();
         foreach ($associations as $associationName => $parameters) {
             $associationMetadata = $factory->create($associationName, $parameters);
             $collection->add($associationMetadata);
         }
         return $collection;
     };
     $resolver->setNormalizer('fields', $fieldsNormalizer);
     $resolver->setNormalizer('associations', $associationsNormalizer);
     $resolver->setDefaults(['fields' => new Collection\FieldMetadataCollection(), 'associations' => new Collection\AssociationMetadataCollection(), 'callbacks' => []]);
     $resolver->setAllowedTypes('fields', ['array', Collection\FieldMetadataCollection::class]);
     $resolver->setAllowedTypes('associations', ['array', Collection\AssociationMetadataCollection::class]);
     $resolver->setAllowedTypes('callbacks', 'array');
 }
开发者ID:WellCommerce,项目名称:ApiBundle,代码行数:31,代码来源:SerializationClassMetadata.php

示例2: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $optionsResolver)
 {
     $validator = $this->validator;
     $optionsResolver->setDefaults(['validation_groups' => ['Default'], 'constraints' => function (Options $options) use($validator) {
         if (null === $options['model_class'] || null === $options['model_property']) {
             return [];
         }
         // Its possible getting of the Metadata gives an error,
         // but that means the model class was invalid already.
         // Getting a property without metadata will give an empty array
         /** @var ClassMetadata $classMetadata */
         $classMetadata = $validator->getMetadataFor($options['model_class']);
         $propertyMetadata = $classMetadata->getPropertyMetadata($options['model_property']);
         $constraints = [];
         foreach ($propertyMetadata as $metadata) {
             $constraints += $metadata->getConstraints();
         }
         return $constraints;
     }]);
     // BC layer for Symfony 2.7 and 3.0
     if ($optionsResolver instanceof OptionsResolverInterface) {
         $optionsResolver->setAllowedTypes(['constraints' => ['array', 'Symfony\\Component\\Validator\\Constraint'], 'validation_groups' => ['array']]);
     } else {
         $optionsResolver->setAllowedTypes('constraints', ['array', 'Symfony\\Component\\Validator\\Constraint']);
         $optionsResolver->setAllowedTypes('validation_groups', ['array']);
     }
 }
开发者ID:rollerworks,项目名称:search-symfony-validator,代码行数:30,代码来源:FieldTypeValidatorExtension.php

示例3: configureOptionResolver

 /**
  * {@inheritdoc}
  */
 protected static function configureOptionResolver(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['host' => '127.0.0.1', 'port' => '6379', 'scheme' => 'tcp']);
     $resolver->setAllowedTypes('host', ['string']);
     $resolver->setAllowedTypes('port', ['string', 'int']);
     $resolver->setAllowedTypes('scheme', ['string']);
 }
开发者ID:aequasi,项目名称:adapter-bundle,代码行数:10,代码来源:DoctrinePredisFactory.php

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

示例5: configureOptions

 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['field', 'form', 'condition']);
     $resolver->setAllowedTypes('field', ElementInterface::class);
     $resolver->setAllowedTypes('form', Form::class);
     $resolver->setAllowedTypes('condition', ConditionInterface::class);
 }
开发者ID:Newman101,项目名称:WellCommerce,代码行数:7,代码来源:AbstractDependency.php

示例6: configureOptions

 /**
  * Configure options
  *
  * @param OptionsResolver $resolver
  * @return void
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['amount']);
     $resolver->setDefined(['currency', 'terminal', 'credit_card_token', 'payment_id']);
     $resolver->setAllowedTypes('credit_card_token', 'string');
     $resolver->setAllowedTypes('payment_id', 'string');
     $resolver->setNormalizer('currency', function (Options $options, $value) {
         if (!isset($options['payment_id'])) {
             $fields = ['terminal', 'credit_card_token', 'currency'];
             foreach ($fields as $field) {
                 if (!isset($options[$field])) {
                     throw new \InvalidArgumentException(sprintf('The fields "%s" is required', implode(', ', $fields)));
                 }
             }
         }
         return $value;
     });
     $resolver->setNormalizer('payment_id', function (Options $options, $value) {
         $fields = ['currency', 'terminal', 'credit_card_token'];
         foreach ($fields as $field) {
             if (isset($options[$field])) {
                 throw new \InvalidArgumentException(sprintf('The fields "%s" is not allowed when "payment_id" is set', implode(', ', $fields)));
             }
         }
         return $value;
     });
 }
开发者ID:lsv,项目名称:altapay-php-api,代码行数:33,代码来源:CalculateSurcharge.php

示例7: configureOptions

 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['label' => false, 'name' => '', 'data_class' => 'RZ\\Roadiz\\Core\\Entities\\Folder', 'attr' => ['class' => 'uk-form folder-form']]);
     $resolver->setRequired(['em']);
     $resolver->setAllowedTypes('em', 'Doctrine\\Common\\Persistence\\ObjectManager');
     $resolver->setAllowedTypes('name', 'string');
 }
开发者ID:QuangDang212,项目名称:roadiz,代码行数:7,代码来源:FolderType.php

示例8: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['column_transformers', 'cache']);
     $resolver->setDefaults(['column_transformers' => new ColumnTransformerCollection(), 'cache' => true]);
     $resolver->setAllowedTypes('column_transformers', ColumnTransformerCollection::class);
     $resolver->setAllowedTypes('cache', 'bool');
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:10,代码来源:AbstractDataSetContext.php

示例9: configureOptions

 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['compound' => true, 'label' => false, 'nodeName' => null, 'attr' => ['class' => 'uk-form transtype-form']]);
     $resolver->setRequired(['em', 'currentType']);
     $resolver->setAllowedTypes('em', 'Doctrine\\Common\\Persistence\\ObjectManager');
     $resolver->setAllowedTypes('currentType', 'RZ\\Roadiz\\Core\\Entities\\NodeType');
 }
开发者ID:QuangDang212,项目名称:roadiz,代码行数:7,代码来源:TranstypeType.php

示例10: configureOptions

 /**
  * Option configuration.
  *
  * @param OptionsResolver $resolver
  */
 private function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefault('url', 'https://news.google.com/news?cf=all&hl=en&ned=us&topic=t&output=rss');
     $resolver->setAllowedTypes('url', array('string'));
     $resolver->setRequired(array('location_id'));
     $resolver->setAllowedTypes('location_id', array('int'));
 }
开发者ID:htollefsen,项目名称:examples,代码行数:12,代码来源:GoogleNewsToEzPlatformContentManifest.php

示例11: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['controller_body' => null, 'angular_modules' => [], 'angular_services' => ['$scope']]);
     $resolver->setAllowedTypes('controller_body', ['null', 'string']);
     $resolver->setAllowedTypes('angular_modules', ['array']);
     $resolver->setAllowedTypes('angular_services', ['array']);
 }
开发者ID:ynloultratech,项目名称:framework,代码行数:10,代码来源:AngularControllerType.php

示例12: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['route', 'group_action']);
     $resolver->setDefaults(['route' => false, 'group_action' => false]);
     $resolver->setAllowedTypes('route', ['bool', 'string']);
     $resolver->setAllowedTypes('group_action', ['bool', 'string']);
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:10,代码来源:DeleteGroupEventHandler.php

示例13: configureOptions

 /**
  * Configure options
  *
  * @param OptionsResolver $resolver
  *
  * @throws \Symfony\Component\OptionsResolver\Exception\ExceptionInterface
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['name' => null, 'label' => null, 'entity' => null]);
     $resolver->setAllowedTypes('name', 'string');
     $resolver->setAllowedTypes('label', ['string', 'null']);
     $resolver->setAllowedTypes('entity', 'string');
 }
开发者ID:sunnyct,项目名称:silexcmf-rest,代码行数:14,代码来源:RestController.php

示例14: 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'));
 }
开发者ID:WildCodeSchool,项目名称:projet-gesty,代码行数:13,代码来源:LunchRepository.php

示例15: configureOptions

 public function configureOptions(OptionsResolver $options)
 {
     $options->setDefaults(['field_options' => []]);
     $options->setRequired(['field_type']);
     $options->setAllowedTypes('field_type', ['string']);
     $options->setAllowedTypes('field_options', ['array']);
 }
开发者ID:symfony-cmf,项目名称:content-type,代码行数:7,代码来源:CollectionType.php


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