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


PHP OptionsResolverInterface::setNormalizer方法代碼示例

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


在下文中一共展示了OptionsResolverInterface::setNormalizer方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: __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('on', ['string', 'array']);
     $this->specResolver->setAllowedTypes('from', ['string', 'array']);
     $this->specResolver->setAllowedTypes('to', ['string', 'array']);
     $this->specResolver->setAllowedTypes('exclude_from', ['string', 'array']);
     $this->specResolver->setAllowedTypes('exclude_to', ['string', 'array']);
     $toArrayNormalizer = function (Options $options, $value) {
         return (array) $value;
     };
     foreach (['on', 'from', 'to', 'exclude_to', 'exclude_from'] as $value) {
         $this->specResolver->setNormalizer($value, $toArrayNormalizer);
     }
 }
開發者ID:chareice,項目名稱:finite,代碼行數:20,代碼來源:CallbackHandler.php

示例3: setDefaultOptions

 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('on' => 'on', 'off' => 'off'));
     $resolver->setNormalizer('attr', function ($options, $value) {
         $value["class"] = "switch-input";
         if (array_key_exists("class", $value)) {
             $value["class"] .= " " . $value["class"];
         }
         return $value;
     });
 }
開發者ID:TMSolution,項目名稱:FormTypeBundle,代碼行數:11,代碼來源:CheckboxSwitchType.php

示例4: setDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $optionsNormalizer = function (Options $options, $value) {
         $value['block_name'] = 'entry';
         return $value;
     };
     $resolver->setDefaults(['allow_add' => false, 'allow_delete' => false, 'prototype' => true, 'prototype_name' => '__name__', 'type_name' => '_type', 'options' => []]);
     $resolver->setRequired(['types']);
     $resolver->setAllowedTypes(['types' => 'array']);
     $resolver->setNormalizer('empty_value', $emptyValueNormalizer);
 }
開發者ID:rseliberty,項目名稱:FormElementTypeBundle,代碼行數:14,代碼來源:PolyCollectionType.php


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