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


PHP ArrayNodeDefinition::defaultValue方法代码示例

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


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

示例1: createStepsNodeDefinition

 /**
  * Create a configuration node to define the steps of a process.
  *
  * @return ArrayNodeDefinition
  */
 private function createStepsNodeDefinition()
 {
     $stepsNode = new ArrayNodeDefinition('steps');
     $stepsNode->defaultValue(array())->useAttributeAsKey('name')->prototype('array')->addDefaultsIfNotSet()->children()->scalarNode('label')->defaultValue('')->end()->arrayNode('roles')->prototype('scalar')->end()->end()->arrayNode('model_status')->validate()->ifTrue(function ($value) {
         return is_array($value) && count($value) < 2;
     })->thenInvalid('You must specify an array with [ method, constant ]')->ifTrue(function ($value) {
         return !defined($value[1]);
     })->thenInvalid('You must specify a valid constant name as second parameter')->end()->prototype('scalar')->end()->end()->scalarNode('on_invalid')->defaultNull()->end()->end()->append($this->createNextStatesNodeDefinition())->end();
     return $stepsNode;
 }
开发者ID:vas24x7,项目名称:workflow-bundle,代码行数:15,代码来源:Configuration.php

示例2: configure

 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     $builder->defaultValue(array('default' => array('enabled' => true, 'type' => null, 'settings' => array())))->treatNullLike(array())->treatFalseLike(array())->useAttributeAsKey('name')->prototype('array')->beforeNormalization()->ifTrue(function ($suite) {
         return is_array($suite) && count($suite);
     })->then(function ($suite) {
         $suite['settings'] = isset($suite['settings']) ? $suite['settings'] : array();
         foreach ($suite as $key => $val) {
             $suiteKeys = array('enabled', 'type', 'settings');
             if (!in_array($key, $suiteKeys)) {
                 $suite['settings'][$key] = $val;
                 unset($suite[$key]);
             }
         }
         return $suite;
     })->end()->normalizeKeys(false)->addDefaultsIfNotSet()->treatTrueLike(array('enabled' => true))->treatNullLike(array('enabled' => true))->treatFalseLike(array('enabled' => false))->children()->booleanNode('enabled')->info('Enables/disables suite')->defaultTrue()->end()->scalarNode('type')->info('Specifies suite type')->defaultValue(null)->end()->arrayNode('settings')->info('Specifies suite extra settings')->defaultValue(array())->useAttributeAsKey('name')->prototype('variable')->end()->end()->end()->end();
 }
开发者ID:OverByThere,项目名称:Behat,代码行数:19,代码来源:SuiteExtension.php

示例3: testPrototypeNodesCantHaveADefaultValueWhenUsingDefaultChildren

 /**
  * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidDefinitionException
  */
 public function testPrototypeNodesCantHaveADefaultValueWhenUsingDefaultChildren()
 {
     $node = new ArrayNodeDefinition('root');
     $node->defaultValue(array())->addDefaultChildrenIfNoneSet('foo')->prototype('array');
     $node->getNode();
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:9,代码来源:ArrayNodeDefinitionTest.php

示例4: configure

 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     $builder->defaultValue(array($this->defaultFormatter => array('enabled' => true)))->useAttributeAsKey('name')->prototype('array')->beforeNormalization()->ifTrue(function ($a) {
         return is_array($a) && !isset($a['enabled']);
     })->then(function ($a) {
         return array_merge($a, array('enabled' => true));
     })->end()->useAttributeAsKey('name')->treatTrueLike(array('enabled' => true))->treatNullLike(array('enabled' => true))->treatFalseLike(array('enabled' => false))->prototype('variable')->end()->end();
 }
开发者ID:OverByThere,项目名称:Behat,代码行数:11,代码来源:OutputExtension.php

示例5: getSubResourcesNode

 /**
  * @return ArrayNodeDefinition
  */
 private function getSubResourcesNode()
 {
     $node = new ArrayNodeDefinition('sub_resources');
     $node->defaultValue([])->prototype('array')->children()->scalarNode('assoc_parent')->end()->scalarNode('assoc_sub')->end()->end()->end();
     return $node;
 }
开发者ID:bitecodes,项目名称:rest-api-generator-bundle,代码行数:9,代码来源:Configuration.php


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