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


PHP OptionsResolverInterface::setDefined方法代码示例

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


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

示例1: initActionOptions

 private function initActionOptions()
 {
     $this->actionOptionsResolver = new OptionsResolver();
     $this->actionOptionsResolver->setRequired(array('route_name'));
     $this->actionOptionsResolver->setDefined(array('element'));
     $self = $this;
     $this->actionOptionsResolver->setDefaults(array('route_name' => function (Options $options) use($self) {
         return $self->getDefaultRouteName($options);
     }, 'additional_parameters' => array(), 'label' => null));
     $this->actionOptionsResolver->setNormalizer('additional_parameters', function (Options $options, $value) use($self) {
         return $self->normalizeAdditionalParameters($options, $value);
     });
     $this->actionOptionsResolver->setAllowedTypes('element', 'string');
     $this->actionOptionsResolver->setAllowedTypes('route_name', 'string');
     $this->actionOptionsResolver->setAllowedTypes('additional_parameters', 'array');
     $this->actionOptionsResolver->setAllowedTypes('label', array('string', 'null'));
 }
开发者ID:kbedn,项目名称:admin-bundle,代码行数:17,代码来源:BatchActionExtension.php

示例2: setDefaultOptions

 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefined('entityName');
     $resolver->setRequired('entityName');
     $resolver->setAllowedTypes('entityName', 'string');
     $resolver->setDefault('invalid_message', function (Options $options) {
         return 'This value is not valid.  Unable to find ' . $options['entityName'] . ' in the database.';
     });
 }
开发者ID:stopfstedt,项目名称:TdnPilotBundle,代码行数:9,代码来源:SingleRelatedType.php

示例3: setDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $compound = function (Options $options) {
         return $options['widget'] !== 'single_text';
     };
     // Defaults to the value of "widget"
     $dateWidget = function (Options $options) {
         return $options['widget'];
     };
     // Defaults to the value of "widget"
     $timeWidget = function (Options $options) {
         return $options['widget'];
     };
     $resolver->setDefaults(array('input' => 'datetime', 'model_timezone' => null, 'view_timezone' => null, 'format' => self::HTML5_FORMAT, 'date_format' => null, 'widget' => null, 'date_widget' => $dateWidget, 'time_widget' => $timeWidget, 'with_minutes' => true, 'with_seconds' => false, 'html5' => true, 'by_reference' => false, 'error_bubbling' => false, 'data_class' => null, 'compound' => $compound));
     // Don't add some defaults in order to preserve the defaults
     // set in DateType and TimeType
     $resolver->setDefined(array('empty_value', 'placeholder', 'years', 'months', 'days', 'hours', 'minutes', 'seconds'));
     $resolver->setAllowedValues(array('input' => array('datetime', 'string', 'timestamp', 'array'), 'date_widget' => array(null, 'single_text', 'text', 'choice'), 'time_widget' => array(null, 'single_text', 'text', 'choice'), 'widget' => array(null, 'single_text', 'text', 'choice')));
 }
开发者ID:Chaireeee,项目名称:chaireeee,代码行数:22,代码来源:DateTimeType.php


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