Eliminando el nodo principal en Symfony TreeBuilder
Frecuentes
Visto 94 equipos
0
i have this yml configuration file:
services:
myservice1: ~
myservice2: ~
My TreeBuilder is:
$rootNode
->children()
->arrayNode('services')
->useAttributeAsKey('serviceName')
->prototype('array')
->children()
->end()
->end()
->end()
->end()
;
But I wish to use the following yml if that is possible:
- myservice1: ~
- myservice2: ~
2 Respuestas
1
Finally i was able to do it with the following Tree Builder
$rootNode = $this->treebuilder->root('DefaultConfigurationRules');
$rootNode
->isRequired()
->cannotBeEmpty()
->prototype('array')
->children()
//
Respondido el 13 de junio de 14 a las 08:06
0
That's impossible, has no point in Symfony2, and is a terrible anti-pattern. The "services" root node is handled by the DPI component and below it the DPI component expects service definitions. All root configuration nodes are specially handled by the registered configuration handlers, like services, parameters, security, framework... In a way it's like a programming language statement. You would get into a collision with other configuration parameters w/out such namespacing. You should wrap all your configuration parameters under properly namespaced names that correspond to your bundle name.
Respondido el 13 de junio de 14 a las 06:06
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas php symfony yaml or haz tu propia pregunta.
Hello. This configuration is not used on the DPI, its for a custom "factory class" with specific needs. - Carlos goce