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