本文整理汇总了PHP中Symfony\Component\Config\Definition\Builder\NodeBuilder类的典型用法代码示例。如果您正苦于以下问题:PHP NodeBuilder类的具体用法?PHP NodeBuilder怎么用?PHP NodeBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRootNode
private function getRootNode()
{
$nodeBuilder = new NodeBuilder();
$rootNode = $nodeBuilder->arrayNode(null);
$this->addConfiguration($rootNode);
return $rootNode->getNode();
}
示例2: addVisitorsSection
private function addVisitorsSection(NodeBuilder $builder)
{
$builder->arrayNode('visitors')->addDefaultsIfNotSet()->children()->arrayNode('json')->addDefaultsIfNotSet()->children()->scalarNode('options')->defaultValue(0)->beforeNormalization()->ifArray()->then(function ($v) {
$options = 0;
foreach ($v as $option) {
if (is_numeric($option)) {
$options |= (int) $option;
} elseif (defined($option)) {
$options |= constant($option);
} else {
throw new InvalidArgumentException('Expected either an integer representing one of the JSON_ constants, or a string of the constant itself.');
}
}
return $options;
})->end()->beforeNormalization()->ifString()->then(function ($v) {
if (is_numeric($v)) {
$value = (int) $v;
} elseif (defined($v)) {
$value = constant($v);
} else {
throw new InvalidArgumentException('Expected either an integer representing one of the JSON_ constants, or a string of the constant itself.');
}
return $value;
})->end()->validate()->always(function ($v) {
if (!is_int($v)) {
throw new InvalidArgumentException('Expected either integer value or a array of the JSON_ constants.');
}
return $v;
})->end()->end()->end()->end()->arrayNode('xml')->fixXmlConfig('whitelisted-doctype', 'doctype_whitelist')->addDefaultsIfNotSet()->children()->arrayNode('doctype_whitelist')->prototype('scalar')->end()->end()->end()->end()->end()->end();
}
示例3: addConfiguration
public function addConfiguration(NodeBuilder $builder)
{
$builder
->scalarNode('provider')->end()
->scalarNode('realm')->defaultValue('Secured Area')->end()
;
}
示例4: addDirectives
private function addDirectives(NodeBuilder $node)
{
$directives = array('default', 'script', 'object', 'style', 'img', 'media', 'frame', 'font', 'connect');
foreach ($directives as $directive) {
$node->arrayNode($directive)->prototype('scalar')->end();
}
return $node;
}
示例5: addOptions
/**
* @param NodeBuilder $nodeBuilder
*
* @return $this
*/
private function addOptions(NodeBuilder $nodeBuilder)
{
// @formatter:off
/** @noinspection PhpUndefinedMethodInspection */
$nodeBuilder->scalarNode('use_revisions')->defaultTrue()->end()->scalarNode('base_host')->isRequired()->end()->scalarNode('base_path')->isRequired()->end();
// @formatter:on
return $this;
}
示例6: testNumericNodeCreation
public function testNumericNodeCreation()
{
$builder = new BaseNodeBuilder();
$node = $builder->integerNode('foo')->min(3)->max(5);
$this->assertInstanceOf('Symfony\\Component\\Config\\Definition\\Builder\\IntegerNodeDefinition', $node);
$node = $builder->floatNode('bar')->min(3.0)->max(5.0);
$this->assertInstanceOf('Symfony\\Component\\Config\\Definition\\Builder\\FloatNodeDefinition', $node);
}
示例7: addConfiguration
public function addConfiguration(NodeBuilder $builder)
{
$builder
->scalarNode('provider')->end()
->scalarNode('user')->defaultValue('SSL_CLIENT_S_DN_Email')->end()
->scalarNode('credentials')->defaultValue('SSL_CLIENT_S_DN')->end()
;
}
示例8: testNodeBuilder
public function testNodeBuilder()
{
$nodeBuilder = new NodeBuilder('root', array());
$childNode = new NodeBuilder('child', array());
$ret = $nodeBuilder->builder($childNode);
$this->assertEquals(array('child' => $childNode), $nodeBuilder->children);
$this->assertEquals($nodeBuilder, $ret);
}
示例9: addSemanticConfig
/**
* Adds semantic configuration definition.
*
* @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system.<siteaccess>
*
* @return void
*/
public function addSemanticConfig(NodeBuilder $nodeBuilder)
{
$nodeBuilder->arrayNode(static::NODE_KEY)->info(static::INFO)->children()->arrayNode('block')->useAttributeAsKey("key")->normalizeKeys(false)->prototype("array")->children()->scalarNode("template")->isRequired()->info("Your template path, as MyBundle:subdir:my_template.html.twig")->end()->scalarNode('controller')->info(<<<EOT
Use custom controller instead of the default one to display a block matching your rules.
You can use the controller reference notation supported by Symfony.
EOT
)->example('MyBundle:MyControllerClass:viewBlock')->end()->arrayNode("match")->info("Condition matchers configuration")->useAttributeAsKey("key")->prototype("variable")->end()->end()->end()->end()->end()->end()->beforeNormalization()->always()->then(function ($v) {
return array('block' => $v);
})->end()->end();
}
示例10: defineGrammar
/**
* @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder
*/
protected function defineGrammar(NodeBuilder $nodeBuilder)
{
$nodeBuilder->scalarNode('framework')->end()->arrayNode('test_targets')->addDefaultsIfNotSet()->children()->arrayNode('resources')->defaultValue(array(ApplicationContext::getInstance()->getEnvironment()->getWorkingDirectoryAtStartup()))->validate()->ifTrue(function ($v) {
return count($v) == 0;
})->then(function ($v) {
return array(ApplicationContext::getInstance()->getEnvironment()->getWorkingDirectoryAtStartup());
})->end()->prototype('scalar')->cannotBeEmpty()->end()->end()->booleanNode('recursive')->defaultFalse()->end()->arrayNode('methods')->defaultValue(array())->prototype('scalar')->cannotBeEmpty()->end()->end()->arrayNode('classes')->defaultValue(array())->prototype('scalar')->cannotBeEmpty()->end()->end()->scalarNode('file_pattern')->defaultNull()->cannotBeEmpty()->end()->end()->end()->arrayNode('autotest')->addDefaultsIfNotSet()->treatNullLike(array('enabled' => true))->treatTrueLike(array('enabled' => true))->treatFalseLike(array('enabled' => false))->children()->booleanNode('enabled')->defaultFalse()->end()->arrayNode('watch_dirs')->defaultValue(array())->prototype('scalar')->cannotBeEmpty()->end()->end()->end()->end()->booleanNode('notify')->defaultFalse()->end()->arrayNode('junit_xml')->addDefaultsIfNotSet()->beforeNormalization()->ifString()->then(function ($v) {
return array('file' => $v);
})->end()->children()->scalarNode('file')->defaultNull()->cannotBeEmpty()->end()->booleanNode('realtime')->defaultFalse()->end()->end()->end()->booleanNode('stop_on_failure')->defaultFalse()->end()->booleanNode('detailed_progress')->defaultFalse()->end();
}
示例11: addSemanticConfig
/**
* Adds semantic configuration definition.
*
* @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system.<siteaccess>
*/
public function addSemanticConfig(NodeBuilder $nodeBuilder)
{
$nodeBuilder->arrayNode('imagemagick')->info('DEPRECATED.')->children()->scalarNode('pre_parameters')->info('Parameters that must be run BEFORE the filenames and filters')->end()->scalarNode('post_parameters')->info('Parameters that must be run AFTER the filenames and filters')->end()->end()->end()->arrayNode('image_variations')->info('Configuration for your image variations (aka "image aliases")')->example(array('my_image_variation' => array('reference' => '~', 'filters' => array(array('name' => 'geometry/scaledownonly', 'params' => array(400, 350)))), 'my_cropped_variation' => array('reference' => 'my_image_variation', 'filters' => array(array('name' => 'geometry/scalewidthdownonly', 'params' => array(300)), array('name' => 'geometry/crop', 'params' => array(300, 300, 0, 0))))))->useAttributeAsKey('variation_name')->normalizeKeys(false)->prototype('array')->children()->scalarNode('reference')->info('Tells the system which original variation to use as reference image. Defaults to original')->example(array('reference' => 'large'))->end()->arrayNode('filters')->info('A list of filters to run, each filter must be supported by the active image converters')->useAttributeAsKey('name')->normalizeKeys(false)->prototype('array')->info('Array/Hash of parameters to pass to the filter')->useAttributeAsKey('options')->beforeNormalization()->ifTrue(function ($v) {
// Check if passed array only contains a "params" key (BC with <=5.3).
return is_array($v) && count($v) === 1 && isset($v['params']);
})->then(function ($v) {
// If we have the "params" key, just use the value.
return $v['params'];
})->end()->prototype('variable')->end()->end()->end()->arrayNode('post_processors')->info('Post processors as defined in LiipImagineBundle. See https://github.com/liip/LiipImagineBundle/blob/master/Resources/doc/filters.md#post-processors')->useAttributeAsKey('name')->prototype('array')->useAttributeAsKey('name')->prototype('variable')->end()->end()->end()->end()->end()->end();
}
示例12: getRelationFieldsNodeDefinition
protected function getRelationFieldsNodeDefinition($level = 1)
{
$nodeBuilder = new NodeBuilder();
$relationFieldsNode = $nodeBuilder->arrayNode('relation_fields');
if ($level < self::RELATION_FIELDS_NODE_MAX_LEVEL) {
$relationFieldsNode->prototype('array')->children()->scalarNode('name')->end()->enumNode('target_type')->values($this->targetTypes)->end()->arrayNode('target_fields')->prototype('scalar')->end()->end()->enumNode('relation_type')->values($this->relationTypes)->end()->append($this->getRelationFieldsNodeDefinition($level + 1))->end()->validate()->ifTrue(function ($value) {
return !empty($value['relation_type']) && empty($value['relation_fields']) || !empty($value['relation_fields']) && empty($value['relation_type']);
})->thenInvalid('Both or none of relation_type and relation_fields should be specified for field')->end()->end();
}
return $relationFieldsNode;
}
示例13: addConfiguration
public function addConfiguration(NodeBuilder $node)
{
$node->scalarNode('provider')->end()->booleanNode('remember_me')->defaultTrue()->end()->scalarNode('success_handler')->end()->scalarNode('failure_handler')->end();
foreach ($this->options as $name => $default) {
if (is_bool($default)) {
$node->booleanNode($name)->defaultValue($default);
} else {
$node->scalarNode($name)->defaultValue($default);
}
}
}
示例14: 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;
}
示例15: addConfiguration
public function addConfiguration(NodeBuilder $node)
{
$node->scalarNode('key')->isRequired()->cannotBeEmpty()->end()->scalarNode('token_provider')->end();
foreach ($this->options as $name => $value) {
if (is_bool($value)) {
$node->booleanNode($name)->defaultValue($value);
} else {
$node->scalarNode($name)->defaultValue($value);
}
}
}