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


PHP NodeBuilder::setNodeClass方法代码示例

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


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

示例1: getConfigTreeBuilder

 public function getConfigTreeBuilder()
 {
     $nodeBuilder = new NodeBuilder();
     $nodeBuilder->setNodeClass('task', __NAMESPACE__ . '\\Builder\\TaskNodeDefinition');
     $nodeBuilder->setNodeClass('transporter', __NAMESPACE__ . '\\Builder\\TransporterNodeDefinition');
     $nodeBuilder->setNodeClass('strategy', __NAMESPACE__ . '\\Builder\\StrategyNodeDefinition');
     $treeBuilder = new TreeBuilder();
     $rootNode = $treeBuilder->root('conveyor', 'array', $nodeBuilder);
     $validSchemes = array('git', 'svn');
     $rootNode->children()->arrayNode('repository')->isRequired()->children()->scalarNode('type')->isRequired()->cannotBeEmpty()->end()->scalarNode('url')->isRequired()->cannotBeEmpty()->end()->end()->beforeNormalization()->ifString()->then(function ($v) {
         $result = parse_url($v);
         if (false === $result) {
             throw new InvalidConfigurationException(sprintf('Could not parse repository url "%s"', $v));
         }
         return array('type' => $result['scheme'], 'url' => $v);
     })->end()->validate()->ifTrue(function ($v) use($validSchemes) {
         return false === in_array($v['type'], $validSchemes);
     })->thenInvalid('Invalid repository type "%s". Valid types are: ' . implode(', ', $validSchemes) . '.')->end()->end()->arrayNode('targets')->prototype('array')->children()->scalarNode('name')->end()->scalarNode('url')->end()->arrayNode('groups')->defaultValue(array())->beforeNormalization()->ifString()->then(function ($v) {
         return array($v);
     })->end()->prototype('scalar')->end()->end()->node('transport', 'transporter')->setTransporterFactory($this->transporterFactory)->isRequired()->beforeNormalization()->ifString()->then(function ($v) {
         $regex = '/^(?P<type>\\w+):\\/\\/(?P<user>\\w+)(:(?P<pass>\\w+))?@(?P<host>[.\\w]+)(:(?P<port>\\w+))?(?P<path>\\/[\\/\\w]+)/';
         if (is_string($v)) {
             if (preg_match($regex, $v, $matches)) {
                 return array('type' => $matches['type'], 'user' => $matches['user'], 'pass' => $matches['pass'] ?: null, 'host' => $matches['host'], 'port' => $matches['port'], 'path' => $matches['path']);
             } else {
                 throw new InvalidConfigurationException(sprintf('Could not parse "%s" as DSN', $v));
             }
         }
         return $v;
     })->end()->end()->arrayNode('parameters')->prototype('scalar')->end()->end()->end()->end()->end()->arrayNode('build')->children()->scalarNode('dir')->defaultValue('/tmp/conveyor')->beforeNormalization()->ifString()->then(function ($v) {
         // resolve home dir
         $path = preg_replace('/^\\~/', getenv('HOME'), $v);
         return $path;
     })->end()->end()->arrayNode('derived')->prototype('array')->children()->scalarNode('source')->end()->scalarNode('derived')->end()->end()->end()->end()->arrayNode('tasks')->prototype('task')->setTaskFactory($this->taskFactory)->children()->arrayNode('targets')->beforeNormalization()->ifString()->then(function ($v) {
         return array($v);
     })->end()->prototype('scalar')->end()->end()->end()->end()->end()->end()->end()->arrayNode('undeploy')->children()->arrayNode('tasks')->prototype('task')->setTaskFactory($this->taskFactory)->children()->arrayNode('targets')->beforeNormalization()->ifString()->then(function ($v) {
         return array($v);
     })->end()->prototype('scalar')->end()->end()->end()->end()->end()->end()->end()->arrayNode('deploy')->addDefaultsIfNotSet()->children()->node('strategy', 'strategy')->beforeNormalization()->ifString()->then(function ($v) {
         return array('type' => $v);
     })->end()->setStrategyFactory($this->strategyFactory)->addDefaultsIfNotSet()->children()->scalarNode('type')->isRequired()->defaultValue('releases')->end()->end()->end()->arrayNode('before')->prototype('task')->setTaskFactory($this->taskFactory)->children()->arrayNode('targets')->beforeNormalization()->ifString()->then(function ($v) {
         return array($v);
     })->end()->prototype('scalar')->end()->end()->end()->end()->end()->arrayNode('after')->prototype('task')->setTaskFactory($this->taskFactory)->children()->arrayNode('targets')->beforeNormalization()->ifString()->then(function ($v) {
         return array($v);
     })->end()->prototype('scalar')->end()->end()->end()->end()->end()->arrayNode('final')->prototype('task')->setTaskFactory($this->taskFactory)->children()->arrayNode('targets')->beforeNormalization()->ifString()->then(function ($v) {
         return array($v);
     })->end()->prototype('scalar')->end()->end()->end()->end()->end()->end()->end()->end();
     return $treeBuilder;
 }
开发者ID:webcreate,项目名称:conveyor,代码行数:48,代码来源:DeployConfiguration.php

示例2: testNodeTypesAreNotCaseSensitive

 public function testNodeTypesAreNotCaseSensitive()
 {
     $builder = new BaseNodeBuilder();
     $node1 = $builder->node('', 'VaRiAbLe');
     $node2 = $builder->node('', 'variable');
     $this->assertEquals(get_class($node1), get_class($node2));
     $builder->setNodeClass('CuStOm', __NAMESPACE__ . '\\SomeNodeDefinition');
     $node1 = $builder->node('', 'CUSTOM');
     $node2 = $builder->node('', 'custom');
     $this->assertEquals(get_class($node1), get_class($node2));
 }
开发者ID:rubao,项目名称:symfony,代码行数:11,代码来源:NodeBuilderTest.php

示例3: getConfigTreeBuilder

 /**
  * {@inheritdoc}
  */
 public function getConfigTreeBuilder()
 {
     $nodeBuilder = new NodeBuilder();
     $nodeBuilder->setNodeClass('dynamicArray', DynamicArrayNodeDefinition::class);
     $treeBuilder = new TreeBuilder();
     $rootNode = $treeBuilder->root('prooph', 'dynamicArray', $nodeBuilder);
     // our factories handles validation and we are flexible with keys
     // Please take a look at the docs or specific prooph component factory for the configuration options
     $rootNode->ignoreExtraKeys(false);
     return $treeBuilder;
 }
开发者ID:proophsoftware,项目名称:prooph-interop-bundle,代码行数:14,代码来源:Configuration.php


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