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