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


PHP OptionsResolver::setNormalizers方法代码示例

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


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

示例1: setNormalizers

 private function setNormalizers()
 {
     $this->resolver->setNormalizers([self::CHARSETS => function (Options $options, $value) {
         $value = array_map('strtoupper', $value);
         $value = $this->replaceWin1250WithIso($value);
         $value = $this->filterSupportedCharsets($value);
         $value = $this->moveUtfFirst($value);
         return $value;
     }]);
 }
开发者ID:brighten01,项目名称:opencloud-zendframework,代码行数:10,代码来源:CharsetOptionsResolver.php

示例2: setNormalizers

 private function setNormalizers()
 {
     $this->resolver->setNormalizers([TCO::RESOURCES => function (Options $options, $resources) {
         $absolutizedResources = [];
         foreach ($resources as $key => $resource) {
             $key = $options['templatesPath'] . '/' . $key;
             $absolutizedResources[$key] = $resource;
         }
         return $absolutizedResources;
     }, TCO::TEMPLATES => function (Options $options, $value) {
         return $this->makeTemplatePathsAbsolute($value, $options);
     }]);
 }
开发者ID:brighten01,项目名称:opencloud-zendframework,代码行数:13,代码来源:ThemeConfigOptionsResolver.php

示例3: configureOptions

 /**
  * Options:
  * - grid_widget_route - route of widget where selection grid will be rendered
  * - grid_name - name of grid that will be used for entity selection
  * - grid_parameters - parameters need to be passed to grid request
  * - grid_render_parameters - render parameters need to be set for grid rendering
  * - existing_entity_grid_id - grid row field name used as entity identifier
  * - create_enabled - enables new entity creation
  * - create_acl - ACL resource used to determine that create is allowed, by default CREATE for entity used
  * - create_form_route - route name for creation form
  * - create_form_route_parameters - route parameters for create_form_route_parameters
  *
  * {@inheritDoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['existing_entity_grid_id' => 'id', 'create_enabled' => true, 'create_acl' => null, 'create_form_route' => null, 'create_form_route_parameters' => [], 'grid_widget_route' => 'oro_datagrid_widget', 'grid_name' => null, 'grid_parameters' => [], 'grid_render_parameters' => []]);
     $resolver->setNormalizers(['create_enabled' => function (Options $options, $createEnabled) {
         $createRouteName = $options->get('create_form_route');
         $createEnabled = $createEnabled && !empty($createRouteName);
         if ($createEnabled) {
             $aclName = $options->get('create_acl');
             if (empty($aclName)) {
                 $aclObjectName = 'Entity:' . $options->get('entity_class');
                 $createEnabled = $this->securityFacade->isGranted('CREATE', $aclObjectName);
             } else {
                 $createEnabled = $this->securityFacade->isGranted($aclName);
             }
         }
         return $createEnabled;
     }, 'grid_name' => function (Options $options, $gridName) {
         if (!empty($gridName)) {
             return $gridName;
         }
         $formConfig = $this->configManager->getProvider('form')->getConfig($options->get('entity_class'));
         if ($formConfig->has('grid_name')) {
             return $formConfig->get('grid_name');
         }
         throw new InvalidConfigurationException('The option "grid_name" must be set.');
     }]);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:41,代码来源:OroEntitySelectOrCreateInlineType.php

示例4: setNormalizers

 private function setNormalizers()
 {
     $this->resolver->setNormalizers([CO::ANNOTATION_GROUPS => function (Options $options, $value) {
         $value = (array) $value;
         if ($options[CO::DEPRECATED]) {
             $value[] = CO::DEPRECATED;
         }
         if ($options[CO::TODO]) {
             $value[] = CO::TODO;
         }
         return array_unique($value);
     }, CO::DESTINATION => function (Options $options, $value) {
         return FileSystem::getAbsolutePath($value);
     }, CO::BASE_URL => function (Options $options, $value) {
         return rtrim($value, '/');
     }, CO::SKIP_DOC_PATH => function (Options $options, $value) {
         $value = (array) $value;
         foreach ($value as $key => $source) {
             $value[$key] = FileSystem::getAbsolutePath($source);
         }
         return $value;
     }, CO::SOURCE => function (Options $options, $value) {
         if (!is_array($value)) {
             $value = [$value];
         }
         foreach ($value as $key => $source) {
             $value[$key] = FileSystem::getAbsolutePath($source);
         }
         return $value;
     }, CO::SOURCE_CODE => function (Options $options) {
         return !$options[CO::NO_SOURCE_CODE];
     }, CO::TEMPLATE_CONFIG => function (Options $options, $value) {
         return FileSystem::getAbsolutePath($value);
     }]);
 }
开发者ID:brighten01,项目名称:opencloud-zendframework,代码行数:35,代码来源:ConfigurationOptionsResolver.php

示例5: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['field' => 'string', 'type' => 'text', 'options' => [], 'allow_add' => true, 'allow_delete' => true]);
     $resolver->setNormalizers(['type' => function () {
         return new StubLocalizedFallbackValueType();
     }, 'options' => function () {
         return [];
     }]);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:12,代码来源:StubLocalizedFallbackValueCollectionType.php

示例6: setNormalizers

 public function setNormalizers(array $normalizers)
 {
     if (!$this->isLatest()) {
         return parent::setNormalizers($normalizers);
     }
     foreach ($normalizers as $option => $normalizer) {
         parent::setNormalizer($option, $normalizer);
     }
     return $this;
 }
开发者ID:mcrumm,项目名称:phlack,代码行数:10,代码来源:OptionsResolver.php

示例7: testNormalizersTransformFinalOptions

 public function testNormalizersTransformFinalOptions()
 {
     $this->resolver->setDefaults(array('foo' => 'bar', 'bam' => 'baz'));
     $this->resolver->setNormalizers(array('foo' => function (Options $options, $value) {
         return $options['bam'] . '[' . $value . ']';
     }));
     $expected = array('foo' => 'baz[bar]', 'bam' => 'baz');
     $this->assertEquals($expected, $this->resolver->resolve(array()));
     $expected = array('foo' => 'boo[custom]', 'bam' => 'boo');
     $this->assertEquals($expected, $this->resolver->resolve(array('foo' => 'custom', 'bam' => 'boo')));
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:11,代码来源:LegacyOptionsResolverTest.php

示例8: configureOptions

 public function configureOptions(OptionsResolver $resolver)
 {
     $addTypeConstraint = function ($options, $value) {
         // Constraint should always be converted to an array
         $value = is_object($value) ? array($value) : (array) $value;
         $value[] = new IpAddress();
         return $value;
     };
     $resolver->setDefaults(array('placeholder' => '192.0.2.193, *.example.com, ...'));
     $resolver->setNormalizers(array('constraints' => $addTypeConstraint));
 }
开发者ID:kleitz,项目名称:bzion,代码行数:11,代码来源:IpType.php

示例9: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('number' => 5, 'configs' => array(), 'expanded' => true, 'choices' => function (Options $options) {
         $choices = array();
         for ($i = 1; $i <= $options['number']; $i++) {
             $choices[$i] = null;
         }
         return $choices;
     }));
     $resolver->setNormalizers(array('expanded' => function (Options $options, $value) {
         return true;
     }));
 }
开发者ID:GeneralMediaCH,项目名称:GenemuFormBundle,代码行数:16,代码来源:RatingType.php

示例10: configureOptions

 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['extension' => 'stockpile', 'directory' => sys_get_temp_dir() . '/stockpile']);
     $resolver->setRequired(['directory']);
     $resolver->setNormalizers(['extension' => function (Options $options, $extension) {
         $extension = Driver::normalizeKey($extension);
         $extension = strtolower($extension);
         $extension = trim($extension, '.');
         return '.' . $extension;
     }, 'directory' => function (Options $options, $directory) {
         return self::normalizeKey($directory);
     }]);
 }
开发者ID:yrizos,项目名称:stockpile,代码行数:13,代码来源:Filesystem.php

示例11: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $configurator = $this->configurator;
     $resolver->setDefaults(array('allow_extra_fields' => true, 'data_class' => function (Options $options) use($configurator) {
         $entity = $options['entity'];
         $entityConfig = $configurator->getEntityConfiguration($entity);
         return $entityConfig['class'];
     }))->setRequired(array('entity', 'view'));
     if ($this->useLegacyFormComponent()) {
         $resolver->setNormalizers(array('attr' => $this->getAttributesNormalizer()));
     } else {
         $resolver->setNormalizer('attr', $this->getAttributesNormalizer());
     }
 }
开发者ID:unexge,项目名称:EasyAdminBundle,代码行数:17,代码来源:EasyAdminFormType.php

示例12: loadTransitions

 /**
  * @param StateMachineInterface $stateMachine
  */
 private function loadTransitions(StateMachineInterface $stateMachine)
 {
     $resolver = new OptionsResolver();
     $resolver->setRequired(array('from', 'to'));
     $resolver->setOptional(array('guard'));
     $resolver->setNormalizers(array('from' => function (Options $options, $v) {
         return (array) $v;
     }, 'guard' => function (Options $options, $v) {
         return !isset($v) ? null : $v;
     }));
     foreach ($this->config['transitions'] as $transition => $config) {
         $config = $resolver->resolve($config);
         $stateMachine->addTransition(new Transition($transition, $config['from'], $config['to'], $config['guard']));
     }
 }
开发者ID:virasak,项目名称:Finite,代码行数:18,代码来源:ArrayLoader.php

示例13: configureOptionsResolver

 public function configureOptionsResolver(OptionsResolver $resolver)
 {
     $allowedProfileTypes = array('Giftcards\\Encryption\\Profile\\Profile');
     $resolver->setRequired(array('profile'));
     if ($this->profileRegistry) {
         $allowedProfileTypes[] = 'string';
         $profileRegistry = $this->profileRegistry;
         $resolver->setNormalizers(array('profile' => function ($_, $profile) use($profileRegistry) {
             if ($profile instanceof Profile) {
                 return $profile;
             }
             return $profileRegistry->get((string) $profile);
         }));
     }
     $resolver->setAllowedTypes(array('profile' => $allowedProfileTypes));
 }
开发者ID:SaveYa,项目名称:Encryption,代码行数:16,代码来源:NoProfileSerializerDeserializerBuilder.php

示例14: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array('data_class' => null, 'multiple' => true, 'render_label' => false, 'model_transformer' => 'Sylius\\Bundle\\TaxonomyBundle\\Form\\DataTransformer\\TaxonSelectionToCollectionTransformer'));
     $resolver->setNormalizers(array('model_transformer' => function (Options $options, $value) {
         if (!is_array($value)) {
             $value = array('class' => $value, 'save_objects' => true);
         } else {
             if (!isset($value['class'])) {
                 $value['class'] = 'Sylius\\Bundle\\TaxonomyBundle\\Form\\DataTransformer\\TaxonSelectionToCollectionTransformer';
             }
             if (!isset($value['save_objects'])) {
                 $value['save_objects'] = true;
             }
         }
         return $value;
     }));
 }
开发者ID:lingoda,项目名称:Sylius,代码行数:20,代码来源:TaxonSelectionType.php

示例15: setUpResolver

 /**
  * @param OptionsResolver $resolver
  * @param string          $integrationType
  */
 protected function setUpResolver(OptionsResolver $resolver, $integrationType)
 {
     $defined = array();
     $defaults = array();
     $options = $this->getOptions();
     foreach ($options as $name => $option) {
         if ($integrationType && !empty($option['for types']) && !in_array($integrationType, $option['for types'])) {
             unset($options[$name]);
             continue;
         }
         if (!empty($option['default'])) {
             $defaults[$name] = $option['default'];
         } else {
             $defined[] = $name;
         }
     }
     $resolver->setDefined($defined);
     $resolver->setDefaults($defaults);
     $required = array();
     $normalizers = array();
     foreach ($options as $name => $option) {
         if (!empty($option['required']) && (empty($option['for types']) || $integrationType)) {
             $required[] = $name;
         }
         if (!empty($option['normalizer'])) {
             $normalizers[$name] = $option['normalizer'];
         }
         if (!empty($option['type'])) {
             $resolver->setAllowedTypes($name, $option['type']);
         }
         if (!empty($option['validator'])) {
             $resolver->setAllowedValues($name, $option['validator']);
         } elseif (!empty($option['options'])) {
             $resolver->setAllowedValues($name, $option['options']);
         }
     }
     $resolver->setRequired($required);
     $resolver->setNormalizers($normalizers);
 }
开发者ID:pjcdawkins,项目名称:platformsh-cli,代码行数:43,代码来源:IntegrationCommand.php


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