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


PHP ArrayNodeDefinition::beforeNormalization方法代码示例

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


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

示例1: addConfiguration

 public function addConfiguration(ArrayNodeDefinition $rootNode)
 {
     $dsnParser = $this->dsnParser;
     $rootNode->beforeNormalization()->always(function ($config) use($dsnParser) {
         if (isset($config['dsn'])) {
             $config = array_merge($config, $dsnParser->parse($config['dsn']));
         }
         if (isset($config[Client::REQUEST_OPTIONS])) {
             $config['request']['options'] = $config[Client::REQUEST_OPTIONS];
             unset($config[Client::REQUEST_OPTIONS]);
         }
         if (isset($config[Client::CURL_OPTIONS])) {
             $config['curl']['options'] = $config[Client::CURL_OPTIONS];
             unset($config[Client::CURL_OPTIONS]);
         }
         if (isset($config[Client::COMMAND_PARAMS])) {
             $config['command']['params'] = $config[Client::COMMAND_PARAMS];
             unset($config[Client::COMMAND_PARAMS]);
         }
         return $config;
     })->end()->children()->scalarNode('public_key')->isRequired()->end()->scalarNode('secret_key')->isRequired()->end()->scalarNode('project_id')->isRequired()->end()->enumNode('protocol')->defaultValue('https')->values(array('http', 'https'))->end()->scalarNode('host')->defaultValue('app.getsentry.com')->end()->scalarNode('path')->defaultValue('/')->end()->scalarNode('port')->defaultNull()->end()->scalarNode('dsn')->end()->variableNode('exception_factory')->end()->arrayNode('request')->children()->arrayNode('options')->prototype('variable')->end()->end()->end()->end()->arrayNode('curl')->children()->arrayNode('options')->prototype('variable')->end()->end()->end()->end()->arrayNode('command')->addDefaultsIfNotSet()->children()->arrayNode('params')->addDefaultsIfNotSet()->children()->scalarNode('level')->end()->scalarNode('logger')->end()->scalarNode('platform')->end()->arrayNode('tags')->prototype('scalar')->end()->end()->arrayNode('extra')->prototype('scalar')->end()->end()->scalarNode('server_name')->defaultValue(gethostname())->end()->end()->end()->end()->end()->arrayNode('ignored_exceptions')->beforeNormalization()->always(function (array $ignoredExceptions) {
         $newIgnoredExceptions = array();
         foreach ($ignoredExceptions as $class => $ignored) {
             if (!is_bool($ignored)) {
                 $class = $ignored;
                 $ignored = true;
             }
             $newIgnoredExceptions[$class] = $ignored;
         }
         return $newIgnoredExceptions;
     })->end()->prototype('scalar')->end()->end()->end();
 }
开发者ID:sc0rp10,项目名称:sentry-client,代码行数:32,代码来源:Configuration.php

示例2: configure

 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $node)
 {
     $node->beforeNormalization()->ifString()->then(function ($v) {
         return array($v);
     })->end()->prototype('array')->beforeNormalization()->ifString()->then(function ($v) {
         return ['pattern' => $v];
     })->end()->children()->scalarNode('pattern')->isRequired()->end()->arrayNode('ignore')->beforeNormalization()->ifNull()->thenEmptyArray()->ifString()->then(function ($v) {
         return array($v);
     })->end()->prototype('scalar')->end()->end()->arrayNode('options')->beforeNormalization()->ifNull()->thenEmptyArray()->end()->prototype('variable')->end()->end()->end()->end();
 }
开发者ID:pamuche,项目名称:openl10n-cli,代码行数:13,代码来源:FilesExtension.php

示例3: getAllowHeaders

 private function getAllowHeaders()
 {
     $node = new ArrayNodeDefinition('allow_headers');
     $node->beforeNormalization()->always(function ($v) {
         if ($v === '*') {
             return array('*');
         }
         return $v;
     })->end()->prototype('scalar')->end();
     return $node;
 }
开发者ID:hason,项目名称:NelmioCorsBundle,代码行数:11,代码来源:Configuration.php

示例4: addDeprecationsSection

 private function addDeprecationsSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->beforeNormalization()->ifTrue(function ($v) {
         return isset($v['list_max_results']);
     })->then(function ($v) {
         if (!isset($v['list'])) {
             $v['list'] = array();
         }
         // if the new option is defined, don't override it with the legacy option
         if (!isset($v['list']['max_results'])) {
             $v['list']['max_results'] = $v['list_max_results'];
         }
         unset($v['list_max_results']);
         return $v;
     })->end()->beforeNormalization()->ifTrue(function ($v) {
         return isset($v['list_actions']);
     })->then(function ($v) {
         // if the new option is defined, don't override it with the legacy option
         if (!isset($v['list']['actions'])) {
             $v['list']['actions'] = $v['list_actions'];
         }
         unset($v['list_actions']);
         return $v;
     })->end()->beforeNormalization()->always()->then(function ($v) {
         if (!isset($v['design'])) {
             $v['design'] = array('assets' => array());
         }
         return $v;
     })->end()->beforeNormalization()->ifTrue(function ($v) {
         return isset($v['assets']['css']);
     })->then(function ($v) {
         // if the new option is defined, don't override it with the legacy option
         if (!isset($v['design']['assets']['css'])) {
             $v['design']['assets']['css'] = $v['assets']['css'];
         }
         unset($v['assets']['css']);
         return $v;
     })->end()->beforeNormalization()->ifTrue(function ($v) {
         return isset($v['assets']['js']);
     })->then(function ($v) {
         // if the new option is defined, don't override it with the legacy option
         if (!isset($v['design']['assets']['js'])) {
             $v['design']['assets']['js'] = $v['assets']['js'];
         }
         unset($v['assets']['js']);
         return $v;
     })->end()->beforeNormalization()->always()->then(function ($v) {
         if (isset($v['assets'])) {
             unset($v['assets']);
         }
         return $v;
     })->end()->children()->variableNode('list_actions')->info('DEPRECATED: use the "actions" option of the "list" view.')->end()->integerNode('list_max_results')->info('DEPRECATED: use "max_results" option under the "list" global key.')->end()->arrayNode('assets')->performNoDeepMerging()->children()->arrayNode('css')->info('DEPRECATED: use the "design -> assets -> css" option.')->end()->arrayNode('js')->info('DEPRECATED: use the "design -> assets -> js" option.')->end()->end()->end()->end();
 }
开发者ID:sebastianlp,项目名称:EasyAdminBundle,代码行数:53,代码来源:Configuration.php

示例5: configure

 /**
  * Setups configuration for the extension.
  *
  * @param ArrayNodeDefinition $builder
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     $default_fixtures = array('admin_user' => '\\Behat\\MageExtension\\Fixture\\AdminUserFixtureFactory', 'cart_product' => '\\Behat\\MageExtension\\Fixture\\CartProductFixtureFactory', 'customer' => '\\Behat\\MageExtension\\Fixture\\CustomerFixtureFactory', 'product' => '\\Behat\\MageExtension\\Fixture\\ProductFixtureFactory', 'configurable_product' => '\\Behat\\MageExtension\\Fixture\\ConfigurableProductFixtureFactory', 'attribute_set' => '\\Behat\\MageExtension\\Fixture\\AttributeSetFixtureFactory', 'attribute' => '\\Behat\\MageExtension\\Fixture\\AttributeFixtureFactory', 'attribute_with_options' => '\\Behat\\MageExtension\\Fixture\\AttributeWithOptionsFixtureFactory');
     $builder->beforeNormalization()->always()->then(function ($v) use($default_fixtures) {
         if (array_key_exists('fixture_factories', $v) && is_array($v['fixture_factories'])) {
             $v['fixture_factories'] = array_merge($default_fixtures, $v['fixture_factories']);
         } else {
             $v['fixture_factories'] = $default_fixtures;
         }
         return $v;
     })->end()->addDefaultsIfNotSet()->children()->scalarNode('default_page_class')->defaultValue('\\Behat\\MageExtension\\Page\\MagePage')->end()->scalarNode('category_page_class')->defaultValue('\\Behat\\MageExtension\\Page\\Category')->end()->scalarNode('product_page_class')->defaultValue('\\Behat\\MageExtension\\Page\\Product')->end()->arrayNode('custom_page_classes')->prototype('scalar')->end()->end()->arrayNode('fixture_factories')->prototype('scalar');
 }
开发者ID:beejhuff,项目名称:behat-magento-extension,代码行数:17,代码来源:MageExtension.php

示例6: addFormSection

 private function addFormSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->beforeNormalization()->ifTrue(function ($v) {
         return isset($v['form']['resources']);
     })->then(function ($v) {
         trigger_error('The twig.form.resources configuration key is deprecated since version 2.6 and will be removed in 3.0. Use the twig.form_themes configuration key instead.', E_USER_DEPRECATED);
         return $v;
     })->end()->validate()->ifTrue(function ($v) {
         return count($v['form']['resources']) > 0;
     })->then(function ($v) {
         $v['form_themes'] = array_values(array_unique(array_merge($v['form']['resources'], $v['form_themes'])));
         return $v;
     })->end()->children()->arrayNode('form')->info('Deprecated since version 2.6, to be removed in 3.0. Use twig.form_themes instead')->addDefaultsIfNotSet()->fixXmlConfig('resource')->children()->arrayNode('resources')->addDefaultChildrenIfNoneSet()->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end()->example(array('MyBundle::form.html.twig'))->validate()->ifNotInArray(array('form_div_layout.html.twig'))->then(function ($v) {
         return array_merge(array('form_div_layout.html.twig'), $v);
     })->end()->end()->end()->end()->end();
 }
开发者ID:RuntyCybin,项目名称:csymfony,代码行数:16,代码来源:Configuration.php

示例7: configure

 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $node)
 {
     $node->beforeNormalization()->ifString()->then(function ($v) {
         $home = getenv('HOME');
         $filepath = $home . '/.openl10n/server.conf';
         $data = array();
         if (file_exists($filepath)) {
             $data = parse_ini_file($filepath, true);
         }
         if (isset($data[$v])) {
             return $data[$v];
         }
         return array('hostname' => $v);
     })->end()->children()->scalarNode('hostname')->isRequired()->cannotBeEmpty()->end()->scalarNode('username')->isRequired()->cannotBeEmpty()->end()->scalarNode('password')->isRequired()->cannotBeEmpty()->end()->booleanNode('use_ssl')->beforeNormalization()->ifString()->then(function ($v) {
         return (bool) $v;
     })->end()->defaultFalse()->end()->integerNode('port')->defaultNull()->end()->end();
 }
开发者ID:pamuche,项目名称:openl10n-cli,代码行数:20,代码来源:ServerExtension.php

示例8: addConfiguration

 public function addConfiguration(ArrayNodeDefinition $rootNode)
 {
     $rootNode->beforeNormalization()->always(function ($config) {
         if (isset($config[OktaClient::REQUEST_OPTIONS])) {
             $config['request']['options'] = $config[OktaClient::REQUEST_OPTIONS];
             unset($config[OktaClient::REQUEST_OPTIONS]);
         }
         if (isset($config[OktaClient::CURL_OPTIONS])) {
             $config['curl']['options'] = $config[OktaClient::CURL_OPTIONS];
             unset($config[OktaClient::CURL_OPTIONS]);
         }
         if (isset($config[OktaClient::COMMAND_PARAMS])) {
             $config['command']['params'] = $config[OktaClient::COMMAND_PARAMS];
             unset($config[OktaClient::COMMAND_PARAMS]);
         }
         return $config;
     })->end()->children()->scalarNode('api_key')->isRequired()->end()->scalarNode('host')->isRequired()->info('org.okta.com')->end()->enumNode('protocol')->defaultValue('https')->values(['http', 'https'])->end()->arrayNode('request')->children()->arrayNode('options')->prototype('variable')->end()->end()->end()->end()->arrayNode('curl')->children()->arrayNode('options')->prototype('variable')->end()->end()->end()->end()->end();
 }
开发者ID:smaft-sarl,项目名称:okta-php-sdk,代码行数:18,代码来源:Configuration.php

示例9: getSitemapHelperNode

 private function getSitemapHelperNode($type, $default)
 {
     $node = new ArrayNodeDefinition($type);
     $node->beforeNormalization()->ifTrue(function ($config) {
         return is_string($config);
     })->then(function ($config) {
         return array($config);
     })->end()->defaultValue($default)->prototype('scalar')->end()->end();
     return $node;
 }
开发者ID:symfony-cmf,项目名称:seo-bundle,代码行数:10,代码来源:Configuration.php

示例10: addExchangeSection

 /**
  * @param ArrayNodeDefinition $node
  * @param bool                $includeDlx
  * @param bool                $includeDelay
  */
 private function addExchangeSection(ArrayNodeDefinition $node, $includeDlx = true, $includeDelay = true)
 {
     $node->addDefaultsIfNotSet();
     $node->beforeNormalization()->ifString()->then(function ($value) {
         return ['type' => $value];
     });
     $exchange = $node->children();
     $exchange->scalarNode('name')->defaultNull()->info('The name to create the exchange with in the AMQP broker');
     $exchange->enumNode('type')->values([Exchg::TYPE_DIRECT, Exchg::TYPE_FANOUT, Exchg::TYPE_TOPIC, Exchg::TYPE_HEADERS])->defaultValue(Exchg::TYPE_DIRECT)->info('The exchange type');
     $exchange->booleanNode('auto_declare')->info('Whether to automatically declare the exchange on cache warmup. Only enable this when you have configure access to the exchange');
     $exchange->scalarNode('connection')->defaultNull();
     $exchange->booleanNode('durable')->defaultTrue();
     $exchange->booleanNode('passive')->defaultFalse();
     $exchange->booleanNode('auto_delete')->defaultFalse();
     $exchange->booleanNode('internal')->defaultFalse();
     $exchange->booleanNode('nowait')->defaultFalse();
     $exchange->arrayNode('arguments')->normalizeKeys(false)->prototype('scalar')->defaultValue([]);
     if ($includeDelay) {
         $exchange->booleanNode('delay')->defaultTrue()->info('Whether to enable delayed messages for this exchange');
     }
     if ($includeDlx) {
         $dlx = $exchange->arrayNode('dlx');
         $dlx->info('Create a dead letter exchange for this exchange');
         $dlx->canBeDisabled();
         // copy the entire exchange configuration here
         $this->addExchangeSection($dlx, false, false);
         $queue = $dlx->children()->arrayNode('queue');
         $this->addQueueSection($queue);
     }
 }
开发者ID:treehouselabs,项目名称:queue-bundle,代码行数:35,代码来源:Configuration.php

示例11: configure

 /**
  * {@inheritDoc}
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     // Rewrite keys to define a shortcut way without allowing conflicts with real keys
     $renamedKeys = array_diff(array_keys($this->driverFactories), array('mink_loader', 'base_url', 'files_path', 'show_auto', 'show_cmd', 'show_tmp_dir', 'default_session', 'javascript_session', 'browser_name', 'sessions'));
     $builder->beforeNormalization()->always()->then(function ($v) use($renamedKeys) {
         foreach ($renamedKeys as $driverType) {
             if (!array_key_exists($driverType, $v) || isset($v['sessions'][$driverType])) {
                 continue;
             }
             $v['sessions'][$driverType][$driverType] = $v[$driverType];
             unset($v[$driverType]);
         }
         return $v;
     })->end()->addDefaultsIfNotSet()->children()->scalarNode('mink_loader')->defaultNull()->end()->scalarNode('base_url')->defaultNull()->end()->scalarNode('files_path')->defaultNull()->end()->booleanNode('show_auto')->defaultFalse()->end()->scalarNode('show_cmd')->defaultNull()->end()->scalarNode('show_tmp_dir')->defaultValue(sys_get_temp_dir())->end()->scalarNode('default_session')->defaultNull()->info('Defaults to the first non-javascript session if any, or the first session otherwise')->end()->scalarNode('javascript_session')->defaultNull()->info('Defaults to the first javascript session if any')->end()->scalarNode('browser_name')->defaultValue('firefox')->end()->end()->end();
     /** @var ArrayNodeDefinition $sessionsBuilder */
     $sessionsBuilder = $builder->children()->arrayNode('sessions')->isRequired()->requiresAtLeastOneElement()->useAttributeAsKey('name')->prototype('array');
     foreach ($this->driverFactories as $factory) {
         $factoryNode = $sessionsBuilder->children()->arrayNode($factory->getDriverName())->canBeUnset();
         $factory->configure($factoryNode);
     }
     $sessionsBuilder->validate()->ifTrue(function ($v) {
         return count($v) > 1;
     })->thenInvalid('You cannot set multiple driver types for the same session')->end()->validate()->ifTrue(function ($v) {
         return count($v) === 0;
     })->thenInvalid('You must set a driver definition for the session.')->end();
 }
开发者ID:epfremmer,项目名称:MinkExtension,代码行数:29,代码来源:MinkExtension.php

示例12: configure

 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $node)
 {
     $node->beforeNormalization()->ifNull()->thenEmptyArray()->end()->prototype('scalar')->end();
 }
开发者ID:pamuche,项目名称:openl10n-cli,代码行数:7,代码来源:OptionsExtension.php

示例13: configure

 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $node)
 {
     $node->beforeNormalization()->ifString()->then(function ($v) {
         return array('slug' => $v);
     })->end()->children()->scalarNode('slug')->isRequired()->cannotBeEmpty()->end()->end();
 }
开发者ID:pamuche,项目名称:openl10n-cli,代码行数:9,代码来源:ProjectExtension.php

示例14: addNormalizationSection

 /**
  * Adds the normalization section.
  *
  * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node The root node.
  */
 protected function addNormalizationSection(ArrayNodeDefinition $node)
 {
     $node->beforeNormalization()->always(function ($value) {
         if (!isset($value['geocoder']) && !isset($value['geocoder_request'])) {
             $value['geocoder'] = array('enabled' => false);
         }
         if (!isset($value['directions']) && !isset($value['directions_request'])) {
             $value['directions'] = array('enabled' => false);
         }
         if (!isset($value['distance_matrix']) && !isset($value['distance_matrix_request'])) {
             $value['distance_matrix'] = array('enabled' => false);
         }
         return $value;
     })->end();
 }
开发者ID:acrobat,项目名称:IvoryGoogleMapBundle,代码行数:20,代码来源:Configuration.php

示例15: configure

 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     $builder->beforeNormalization()->ifString()->then(function ($path) {
         return array('' => $path);
     })->end()->defaultValue($this->defaultPaths)->treatTrueLike($this->defaultPaths)->treatNullLike(array())->treatFalseLike(array())->prototype('scalar')->end();
 }
开发者ID:OverByThere,项目名称:Behat,代码行数:9,代码来源:AutoloaderExtension.php


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