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


PHP Builder\NodeDefinition类代码示例

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


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

示例1: addConfiguration

 public function addConfiguration(NodeDefinition $node)
 {
     $node->fixXmlConfig('user_provider');
     $builder = $node->beforeNormalization()->ifTrue(function ($v) {
         return isset($v['key']);
     })->then(function ($v) {
         if (isset($v['secret'])) {
             throw new \LogicException('Cannot set both key and secret options for remember_me, use only secret instead.');
         }
         @trigger_error('remember_me.key is deprecated since version 2.8 and will be removed in 3.0. Use remember_me.secret instead.', E_USER_DEPRECATED);
         $v['secret'] = $v['key'];
         unset($v['key']);
         return $v;
     })->end()->children();
     $builder->scalarNode('secret')->isRequired()->cannotBeEmpty()->end()->scalarNode('token_provider')->end()->arrayNode('user_providers')->beforeNormalization()->ifString()->then(function ($v) {
         return array($v);
     })->end()->prototype('scalar')->end()->end()->scalarNode('catch_exceptions')->defaultTrue()->end();
     foreach ($this->options as $name => $value) {
         if (is_bool($value)) {
             $builder->booleanNode($name)->defaultValue($value);
         } else {
             $builder->scalarNode($name)->defaultValue($value);
         }
     }
 }
开发者ID:tsurune,项目名称:Pruebas,代码行数:25,代码来源:RememberMeFactory.php

示例2: getConfigTreeExtension

 /**
  * Generates the configuration tree builder.
  *
  */
 public function getConfigTreeExtension(NodeDefinition $rootNode)
 {
     $rootNode->children()->scalarNode('min')->isRequired()->info('Starting Number')->example('A numeric number like 1 or 1.67 or 0.87')->validate()->ifTrue(function ($v) {
         return !is_numeric($v);
     })->then(function ($v) {
         throw new EngineException('Range::min Numeric is required');
     })->end()->end()->scalarNode('max')->isRequired()->example('A numeric number like 1 or 1.67 or 0.87')->info('The maxium to use in range')->validate()->ifTrue(function ($v) {
         return !is_numeric($v);
     })->then(function ($v) {
         throw new EngineException('Range::max Numeric is required');
     })->end()->end()->scalarNode('step')->defaultValue(false)->example('1 , 1.5 , 0.6')->info('Stepping value applied on every increment, not supplied will use random')->validate()->ifTrue(function ($v) {
         return !(is_numeric($v) || $v === false);
     })->then(function ($v) {
         throw new EngineException('Range::Step option should be numeric or bool(false) to use random step');
     })->end()->end()->scalarNode('windowStep')->info('Value to add to the base after the iteration has finished (reached max)')->example(1)->defaultValue(0)->validate()->ifTrue(function ($x) {
         return !is_numeric($x);
     })->then(function ($x) {
         throw new EngineException('Range:: windowStep must be an number');
     })->end()->end()->booleanNode('random')->defaultFalse()->example('false|true')->info('Enable random step value on every loop, step param must be set to false')->end()->scalarNode('round')->defaultValue(0)->example('an integer')->info('number of places to round too')->validate()->ifTrue(function ($v) {
         return !(is_integer($v) && $v > 0);
     })->then(function ($v) {
         throw new EngineException('Range::Round option should be a positive integer >= 0');
     })->end()->end()->end();
     return $rootNode;
 }
开发者ID:icomefromthenet,项目名称:faker,代码行数:29,代码来源:Range.php

示例3: addConfiguration

 public function addConfiguration(NodeDefinition $node)
 {
     $node
         ->children()
         ->end()
     ;
 }
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:7,代码来源:NullAdapterFactory.php

示例4: validateDriver

 /**
  * @param NodeDefinition $node
  * @param string         $driver
  * @param string         $option
  *
  * @return self
  */
 private function validateDriver(NodeDefinition $node, $driver, $option)
 {
     $node->validate()->ifTrue(function ($v) use($driver, $option) {
         return $driver === $v['driver'] && empty($v['options'][$option]);
     })->thenInvalid(sprintf('The "%s" option must be defined when using the "%s" driver.', $option, $driver))->end();
     return $this;
 }
开发者ID:johanderuijter,项目名称:BernardBundle,代码行数:14,代码来源:Configuration.php

示例5: addConfiguration

 /**
  * {@inheritdoc}
  */
 public function addConfiguration(NodeDefinition $node)
 {
     $node->fixXmlConfig('header')->children()->scalarNode('auth_header')->cannotBeEmpty()->defaultValue('Authorization')->end()->scalarNode('service_label')->cannotBeEmpty()->defaultValue('HMAC')->end()->scalarNode('algorithm')->beforeNormalization()->ifString()->then(function ($v) {
         return strtolower($v);
     })->end()->validate()->ifNotInArray(hash_algos())->thenInvalid('value %s is not supported, see hash_algos() for available hashing algorithms.')->end()->defaultValue('sha256')->end()->arrayNode('verify_headers')->beforeNormalization()->ifString()->then(function ($v) {
         return array_map('trim', explode(',', $v));
     })->end()->prototype('scalar')->end()->end()->end();
 }
开发者ID:wridgers,项目名称:GremoHmacAuthenticationBundle,代码行数:11,代码来源:HmacFactory.php

示例6: addConfiguration

 public function addConfiguration(NodeDefinition $node)
 {
     $node
         ->children()
             ->scalarNode('client')->isRequired()->end()
         ->end()
     ;
 }
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:8,代码来源:GridFSFactory.php

示例7: addHandlersSection

 /**
  * @param NodeDefinition $node
  * @param                $name
  * @param string $info block info line
  * @param ConfigurationFactory[]|ArrayObject $factories
  */
 private function addHandlersSection(NodeDefinition $node, $name, $info, ArrayObject &$factories)
 {
     $handlersNodeBuilder = $node->children()->arrayNode($name)->info($info)->useAttributeAsKey('name')->prototype('array')->performNoDeepMerging()->children();
     foreach ($factories as $name => $factory) {
         $factoryNode = $handlersNodeBuilder->arrayNode($name)->canBeUnset();
         $factory->addConfiguration($factoryNode);
     }
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:14,代码来源:Configuration.php

示例8: getConfigTreeExtension

 /**
  * Generates the configuration tree builder.
  *
  */
 public function getConfigTreeExtension(NodeDefinition $rootNode)
 {
     $rootNode->children()->booleanNode('value')->isRequired()->validate()->ifTrue(function ($v) {
         return !empty($v);
     })->then(function ($v) {
         return (bool) $v;
     })->end()->info('true or false')->example('true | false')->end()->end();
     return $rootNode;
 }
开发者ID:icomefromthenet,项目名称:faker,代码行数:13,代码来源:BooleanType.php

示例9: getConfigTreeExtension

 public function getConfigTreeExtension(NodeDefinition $rootNode)
 {
     $rootNode->children()->scalarNode('probability')->isRequired()->info('')->example('0.3 | 0.4 | 0.5')->validate()->ifTrue(function ($v) {
         return !is_numeric($v) || !($v > 0 && $v < 1);
     })->then(function ($v) {
         throw new EngineException('PickSelector::Probability must be between 0 and  1');
     })->end()->end()->end();
     return $rootNode;
 }
开发者ID:icomefromthenet,项目名称:faker,代码行数:9,代码来源:PickSelector.php

示例10: getConfigTreeExtension

 public function getConfigTreeExtension(NodeDefinition $rootNode)
 {
     $rootNode->children()->scalarNode('badOption')->treatNullLike('en')->defaultValue('en')->info('Abad option')->validate()->ifTrue(function ($v) {
         return $v === 'bad';
     })->then(function ($v) {
         throw new InvalidConfigurationException('BadOption is equal to bad');
     })->end()->end();
     return $rootNode;
 }
开发者ID:icomefromthenet,项目名称:faker,代码行数:9,代码来源:MockDatasource.php

示例11: configureNode

 public static function configureNode(NodeDefinition $node)
 {
     $node->children()->arrayNode("tags")->prototype("scalar")->end()->end()->scalarNode("query")->end()->booleanNode("filter_by_run_id")->end()->integerNode("limit")->defaultValue(10)->end()->arrayNode("processed_tags")->prototype("scalar")->end()->end()->end()->validate()->ifTrue(function ($v) {
         if ((!isset($v["tags"]) || count($v["tags"]) == 0) && !isset($v["query"])) {
             return true;
         }
         return false;
     })->thenInvalid("At least one of 'tags' or 'query' parameters must be defined.");
 }
开发者ID:keboola,项目名称:input-mapping,代码行数:9,代码来源:File.php

示例12: addConfiguration

 public function addConfiguration(NodeDefinition $node)
 {
     $node
         ->children()
             ->scalarNode('container')->isRequired()->end()
             ->scalarNode('prefix')->defaultNull()->end()
         ->end()
     ;
 }
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:9,代码来源:RackspaceFactory.php

示例13: processNode

 protected function processNode(NodeDefinition $definition, array $config, $sectionName = true)
 {
     $processor = new Processor();
     $node = $definition->getNode(true);
     if ($sectionName) {
         $config = [$node->getName() => $config];
     }
     return $processor->process($node, $config);
 }
开发者ID:coyl,项目名称:EventBandSymfonyBundle,代码行数:9,代码来源:SectionConfigurationTestCase.php

示例14: getConfigTreeExtension

 public function getConfigTreeExtension(NodeDefinition $rootNode)
 {
     $rootNode->children()->scalarNode('set')->isRequired()->info('The size of the set to pick from')->example('1 | 2 | 3')->validate()->ifTrue(function ($v) {
         return !is_integer($v) || (int) $v < 1;
     })->then(function ($v) {
         throw new EngineException('RandomSelector::Set size is required and must be and integer > 0');
     })->end()->end()->end();
     return $rootNode;
 }
开发者ID:icomefromthenet,项目名称:faker,代码行数:9,代码来源:RandomSelector.php

示例15: addConfiguration

 public function addConfiguration(NodeDefinition $node)
 {
     $node
         ->children()
             ->scalarNode('client')->isRequired()->end()
             ->scalarNode('key')->defaultValue('flysystem')->end()
             ->scalarNode('expires')->defaultNull()->end()
         ->end()
     ;
 }
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:10,代码来源:MemcachedFactory.php


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