當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。