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


PHP OptionsResolver::setAllowedValues方法代码示例

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


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

示例1: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(array('relative_path'));
     $resolver->setRequired(array('imagine_filter'));
     $resolver->setDefaults(array('class' => '', 'padding' => '', 'name' => '', 'orderable' => false, 'searchable' => false, 'title' => '', 'type' => '', 'visible' => true, 'width' => '', 'search_type' => 'like', 'filter_type' => 'text', 'filter_options' => array(), 'filter_property' => '', 'filter_search_column' => '', 'holder_url' => '', 'holder_width' => '50', 'holder_height' => '50', 'enlarge' => false));
     $resolver->setAllowedTypes('class', 'string');
     $resolver->setAllowedTypes('padding', 'string');
     $resolver->setAllowedTypes('name', 'string');
     $resolver->setAllowedTypes('orderable', 'bool');
     $resolver->setAllowedTypes('searchable', 'bool');
     $resolver->setAllowedTypes('title', 'string');
     $resolver->setAllowedTypes('type', 'string');
     $resolver->setAllowedTypes('visible', 'bool');
     $resolver->setAllowedTypes('width', 'string');
     $resolver->setAllowedTypes('search_type', 'string');
     $resolver->setAllowedTypes('filter_type', 'string');
     $resolver->setAllowedTypes('filter_options', 'array');
     $resolver->setAllowedTypes('filter_property', 'string');
     $resolver->setAllowedTypes('filter_search_column', 'string');
     $resolver->setAllowedTypes('imagine_filter', 'string');
     $resolver->setAllowedTypes('relative_path', 'string');
     $resolver->setAllowedTypes('holder_url', 'string');
     $resolver->setAllowedTypes('holder_width', 'string');
     $resolver->setAllowedTypes('holder_height', 'string');
     $resolver->setAllowedTypes('enlarge', 'bool');
     $resolver->setAllowedValues('search_type', array('like', 'notLike', 'eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'in', 'notIn', 'isNull', 'isNotNull'));
     $resolver->setAllowedValues('filter_type', array('text', 'select'));
     return $this;
 }
开发者ID:bigz,项目名称:datatablesbundle,代码行数:32,代码来源:GalleryColumn.php

示例2: configureOptions

 /**
  * @param OptionsResolver $resolver
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['allowed', 'default_order']);
     $resolver->setDefaults(['allowed' => true, 'default_order' => self::SORT_DIR_DESC]);
     $resolver->setAllowedValues('allowed', [true, false]);
     $resolver->setAllowedValues('default_order', [self::SORT_DIR_DESC, self::SORT_DIR_ASC]);
 }
开发者ID:Newman101,项目名称:WellCommerce,代码行数:10,代码来源:Sorting.php

示例3: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array_merge($this->getDefaultWidgetOptions(), ['widget' => 'single_text', 'format' => null, 'date_format' => \IntlDateFormatter::MEDIUM, 'time_format' => \IntlDateFormatter::SHORT, 'widget_addon_append' => ['icon' => 'calendar']]));
     $resolver->setAllowedTypes('format', ['null', 'string']);
     $resolver->setAllowedValues('date_format', [\IntlDateFormatter::FULL, \IntlDateFormatter::LONG, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT]);
     $resolver->setAllowedValues('time_format', [\IntlDateFormatter::NONE, \IntlDateFormatter::FULL, \IntlDateFormatter::LONG, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT]);
 }
开发者ID:rafrsr,项目名称:form-extra-bundle,代码行数:10,代码来源:DateTimePickerType.php

示例4: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('color' => 'green', 'switch_type' => 1));
     $resolver->setRequired(array('switch_type'));
     $resolver->setAllowedValues('color', array('green', 'red', 'purple', 'orange', 'dark'));
     $resolver->setAllowedValues('switch_type', array(1, 2, 3, 4, 5, 6, 7));
 }
开发者ID:NobletSolutions,项目名称:AceBundle,代码行数:10,代码来源:SliderType.php

示例5: configureOptions

 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefault('widget', 'compact');
     $resolver->setAllowedValues('widget', ['browser', 'compact']);
     $resolver->setDefault('root_node', '/');
     $resolver->setAllowedValues('root_node', function ($value) {
         return '/' === $value[0];
     });
     $resolver->setDefault('repository_name', 'default');
 }
开发者ID:symfony-cmf,项目名称:tree-browser-bundle,代码行数:10,代码来源:TreeSelectType.php

示例6: setOptions

 /**
  * @inheritdoc
  */
 public function setOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['forced', 'feed', 'date_locale', 'number_locale', 'default_values']);
     $resolver->setAllowedValues('date_locale', ['en', 'nl']);
     $resolver->setAllowedValues('number_locale', ['en', 'nl']);
     $resolver->setAllowedTypes('forced', 'bool');
     $resolver->setAllowedTypes('feed', Feed::class);
     $resolver->setAllowedTypes('default_values', 'array');
     $resolver->setDefaults(['forced' => false, 'date_locale' => 'en', 'number_locale' => 'en', 'default_values' => []]);
 }
开发者ID:treehouselabs,项目名称:io-bundle,代码行数:13,代码来源:AbstractFeedType.php

示例7: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('widget_form_control_class' => 'form-control', 'widget_form_group' => true, 'widget_addon_prepend' => null, 'widget_addon_append' => null, 'widget_btn_prepend' => null, 'widget_btn_append' => null, 'widget_prefix' => null, 'widget_suffix' => null, 'widget_type' => '', 'widget_items_attr' => array(), 'widget_form_group_attr' => array('class' => 'form-group'), 'widget_checkbox_label' => $this->options['checkbox_label']));
     if (version_compare(Kernel::VERSION, '2.6', '>=')) {
         $resolver->setAllowedValues('widget_type', array('inline', 'inline-btn', ''));
         $resolver->setAllowedValues('widget_checkbox_label', array('label', 'widget', 'both'));
     } else {
         $resolver->setAllowedValues(array('widget_type' => array('inline', 'inline-btn', ''), 'widget_checkbox_label' => array('label', 'widget', 'both')));
     }
 }
开发者ID:Hy369,项目名称:MopaBootstrapBundle,代码行数:13,代码来源:WidgetFormTypeExtension.php

示例8: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['input' => 'datetime', 'model_timezone' => null, 'view_timezone' => null, 'date_format' => \IntlDateFormatter::MEDIUM, 'time_format' => \IntlDateFormatter::MEDIUM, 'calendar' => \IntlDateFormatter::GREGORIAN, 'format' => null]);
     $resolver->setAllowedValues('date_format', self::$acceptedFormats);
     $resolver->setAllowedValues('time_format', self::$acceptedFormats);
     $resolver->setAllowedTypes('model_timezone', ['null', 'string']);
     $resolver->setAllowedTypes('view_timezone', ['null', 'string']);
     $resolver->setAllowedTypes('format', ['null', 'string']);
     $resolver->setAllowedTypes('calendar', ['int', 'IntlCalendar']);
     $resolver->setAllowedValues('input', ['string', 'timestamp', 'datetime']);
 }
开发者ID:rollerworks,项目名称:datagrid,代码行数:14,代码来源:DateTimeType.php

示例9: configureOptions

 /**
  * @param OptionsResolver $resolver
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['visible', 'width', 'align', 'no_title']);
     $resolver->setDefaults(['visible' => true, 'width' => self::WIDTH_AUTO, 'align' => self::ALIGN_LEFT, 'no_title' => false]);
     $resolver->setAllowedValues('visible', [true, false]);
     $resolver->setAllowedValues('align', [self::ALIGN_LEFT, self::ALIGN_CENTER, self::ALIGN_RIGHT]);
     $resolver->setAllowedValues('no_title', [true, false]);
     $resolver->setAllowedTypes('visible', 'bool');
     $resolver->setAllowedTypes('width', ['int', 'string']);
     $resolver->setAllowedTypes('align', 'string');
     $resolver->setAllowedTypes('no_title', 'bool');
 }
开发者ID:Newman101,项目名称:WellCommerce,代码行数:15,代码来源:Appearance.php

示例10: __construct

 public function __construct(ConnectionInterface $connection, $dn, $query, array $options = array())
 {
     $resolver = new OptionsResolver();
     $resolver->setDefaults(array('filter' => '*', 'maxItems' => 0, 'sizeLimit' => 0, 'timeout' => 0, 'deref' => static::DEREF_NEVER, 'attrsOnly' => 0, 'scope' => static::SCOPE_SUB));
     $resolver->setAllowedValues('deref', array(static::DEREF_ALWAYS, static::DEREF_NEVER, static::DEREF_FINDING, static::DEREF_SEARCHING));
     $resolver->setAllowedValues('scope', array(static::SCOPE_BASE, static::SCOPE_ONE, static::SCOPE_SUB));
     $resolver->setNormalizer('filter', function (Options $options, $value) {
         return is_array($value) ? $value : array($value);
     });
     $this->connection = $connection;
     $this->dn = $dn;
     $this->query = $query;
     $this->options = $resolver->resolve($options);
 }
开发者ID:symfony,项目名称:ldap,代码行数:14,代码来源:AbstractQuery.php

示例11: configureOptions

 protected function configureOptions(OptionsResolver $resolver)
 {
     // Set default options.
     $resolver->setDefaults(array('clean-strategy' => self::CLEAN_STRATEGY_STANDARD, 'element-blacklist' => '', 'indent-spaces' => 4, 'output' => self::OUTPUT_COMPACT, 'type-blacklist' => Token::CDATA . ',' . Token::COMMENT));
     // Validation
     // clean-strategy
     $resolver->setAllowedTypes('clean-strategy', 'string');
     $resolver->setAllowedValues('clean-strategy', array(self::CLEAN_STRATEGY_NONE, self::CLEAN_STRATEGY_LENIENT, self::CLEAN_STRATEGY_STANDARD, self::CLEAN_STRATEGY_AGGRESSIVE));
     // element-blacklist
     $resolver->setAllowedTypes('element-blacklist', 'string');
     $resolver->setNormalizer('element-blacklist', function (Options $options, $value) {
         $valueArray = explode(',', $value);
         $formattedValueArray = array();
         foreach ($valueArray as $data) {
             $formattedValueArray[] = trim(strtolower($data));
         }
         return implode(',', $formattedValueArray);
     });
     // indent-spaces
     $resolver->setAllowedTypes('indent-spaces', 'int');
     $resolver->setAllowedValues('indent-spaces', function ($value) {
         return $value >= 0;
     });
     // output
     $resolver->setAllowedTypes('output', 'string');
     $resolver->setAllowedValues('output', array(self::OUTPUT_COMPACT, self::OUTPUT_PRETTY));
     // type-blacklist
     $resolver->setAllowedTypes('type-blacklist', 'string');
     $resolver->setAllowedValues('type-blacklist', function ($value) {
         if ($value == '') {
             return true;
         }
         $acceptedValues = array(Token::CDATA, Token::COMMENT, Token::DOCTYPE, Token::ELEMENT, Token::PHP, Token::TEXT);
         $valueArray = explode(',', $value);
         foreach ($valueArray as $val) {
             if (array_search(trim(strtolower($val)), $acceptedValues) === false) {
                 return false;
             }
         }
         return true;
     });
     $resolver->setNormalizer('type-blacklist', function (Options $options, $value) {
         $valueArray = explode(',', $value);
         $formattedValueArray = array();
         foreach ($valueArray as $data) {
             $formattedValueArray[] = trim(strtolower($data));
         }
         return implode(',', $formattedValueArray);
     });
 }
开发者ID:kevintweber,项目名称:groundskeeper,代码行数:50,代码来源:Configuration.php

示例12: setOptions

 /**
  * @param array $options
  */
 public function setOptions($options = array())
 {
     $resolver = new OptionsResolver();
     $resolver->setDefaults(array());
     $resolver->setRequired('slider_id');
     $resolver->setAllowedTypes('slider_id', 'string');
     $resolver->setRequired('start');
     $resolver->setAllowedTypes('start', 'array');
     $resolver->setRequired('range_min');
     $resolver->setAllowedTypes('range_min', 'numeric');
     $resolver->setRequired('range_max');
     $resolver->setAllowedTypes('range_max', 'numeric');
     $resolver->setDefined('range_steps');
     $resolver->setAllowedTypes('range_steps', 'array');
     $resolver->setDefined('step');
     $resolver->setAllowedTypes('step', 'numeric');
     $resolver->setDefined('connect');
     $resolver->setAllowedTypes('connect', 'string');
     $resolver->setAllowedValues('connect', array('lower', 'upper', 'true', 'false'));
     $resolver->setDefault('connect', 'false');
     $resolver->setDefined('margin');
     $resolver->setAllowedTypes('margin', 'numeric');
     $resolver->setDefined('limit');
     $resolver->setAllowedTypes('margin', 'numeric');
     $resolver->setDefined('orientation');
     $resolver->setAllowedTypes('orientation', 'string');
     $resolver->setAllowedValues('orientation', array('vertical', 'horizontal'));
     $resolver->setDefault('orientation', 'horizontal');
     $resolver->setDefined('slider_dimension');
     $resolver->setAllowedTypes('slider_dimension', 'array');
     $resolver->setDefined('direction');
     $resolver->setAllowedTypes('direction', 'string');
     $resolver->setAllowedValues('direction', array('ltr', 'rtl'));
     $resolver->setDefault('direction', 'ltr');
     $resolver->setDefined('animate');
     $resolver->setAllowedTypes('animate', 'boolean');
     $resolver->setDefault('animate', true);
     $resolver->setDefined('animation_duration');
     $resolver->setAllowedTypes('animation_duration', 'numeric');
     $resolver->setDefined('tooltips');
     $resolver->setAllowedTypes('tooltips', 'array');
     //events
     $resolver->setDefined('update_event');
     $resolver->setDefined('change_event');
     $resolver->setDefined('set_event');
     $resolver->setDefined('slide_event');
     $resolver->setDefined('start_event');
     $resolver->setDefined('end_event');
     $this->options = $resolver->resolve($options);
 }
开发者ID:silviomessi,项目名称:sliderbundle,代码行数:53,代码来源:Slider.php

示例13: __construct

 public function __construct()
 {
     $this->allowedTypes = array_merge(array('driver' => array('string'), 'options' => array('array', 'null'), 'attributes' => array('array')), $this->allowedTypes);
     $this->allowedValues = array_merge(array('driver' => array($this->driver)), $this->allowedValues);
     $this->defaults = array_merge(array('driver' => $this->driver, 'options' => array(), 'attributes' => array()), $this->defaults);
     $this->resolver = new OptionsResolver();
     $this->resolver->setRequired($this->required)->setDefaults($this->defaults);
     foreach ($this->allowedValues as $option => $value) {
         $this->resolver->setAllowedValues($option, $value);
     }
     foreach ($this->allowedTypes as $option => $value) {
         $this->resolver->setAllowedTypes($option, $value);
     }
 }
开发者ID:0mcandal0,项目名称:PdoServiceProvider,代码行数:14,代码来源:PdoConfig.php

示例14: configureOptions

 /**
  *
  * @param OptionsResolver $resolver
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(array('class', 'type'));
     $resolver->setDefined(array('create_options', 'modal_size'));
     $resolver->setDefaults(array('include_button' => true, 'include_form' => true, 'error_bubbling' => false, 'entity_options' => array()));
     $resolver->setAllowedValues('modal_size', array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12));
 }
开发者ID:NobletSolutions,项目名称:AceBundle,代码行数:11,代码来源:EntityOrCreateType.php

示例15: configureOptions

 public function configureOptions(OptionsResolver $resolver)
 {
     // Les valeurs par défault
     $resolver->setDefaults(array("host" => "smtp.example.org", "username" => "user", "password" => 'pa$$word', "port" => "25", 'encryption' => null));
     // Les options obligatoire
     $resolver->setRequired(array('host', 'username', 'password'));
     // Les type de valeur autorisé pour le port
     $resolver->setAllowedTypes("port", array("int"));
     // Les valeur autorisé pour l'username
     $resolver->setAllowedValues("username", array("john", "doe", "johndoe"));
     // On normalise le host en fornction de l'encryption ssl ou non
     $resolver->setNormalizer("host", function (Options $options, $value) {
         if (!in_array(substr($value, 0, 7), array("http://", "https://"))) {
             if ("ssl" === $options["encryption"]) {
                 $value = "https://" . $value;
             } else {
                 $value = "http://" . $value;
             }
             return $value;
         }
     });
     // On change la valeur par défault du port en fonction de l'encryption ssl ou non
     $resolver->setDefault("port", function (Options $options) {
         if ("ssl" === $options["encryption"]) {
             return 465;
         }
         return 25;
     });
 }
开发者ID:jeanpasqualini-lesson,项目名称:lesson-option-resolver,代码行数:29,代码来源:Mailer.php


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