Replies: 1 suggested answer
-
I took a deep look at the source code but I couldn't find any fluent solution. I have a solution a bit ugly in the last case. I'm going to change in future when I have it. <?php
namespace Tug\SeoBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('tug_seo');
$rootNodeBuilder = $treeBuilder->getRootNode()->children();
$this->addParametersNode($rootNodeBuilder
->arrayNode('default')
->children());
$this->addParametersNode($rootNodeBuilder
->arrayNode('routes')
->arrayPrototype()
->children());
return $treeBuilder;
}
public function addParametersNode(NodeBuilder $builder)
{
$builder
->scalarNode('title')->end()
->scalarNode('description')->end();
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm able to achieve the concept in following sample but I don't want to nest snippet's parameters (title and description) under a parent (parameters).
I just want to append shallow sample of the snippet like a similar concept of DOM
document.createDocumentFragment()
.I tried to achieve using
NodeBuilder
instead ofTreeBuilder
but I'm not successful. MaybeArrayNodeDefinition#setBuilder()
method can solve this but it is not a fluent method and it breaks the chain.Beta Was this translation helpful? Give feedback.