[Config] Introduce BuilderAwareInterface

This commit is contained in:
Roland Franssen 2018-02-25 10:49:14 +01:00 committed by Nicolas Grekas
parent d203ee3395
commit 1353694bfd
3 changed files with 24 additions and 4 deletions

View File

@ -0,0 +1,22 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Config\Definition\Builder;
/**
* An interface that can be implemented by nodes which build other nodes.
*
* @author Roland Franssen <franssen.roland@gmail.com>
*/
interface BuilderAwareInterface
{
public function setBuilder(NodeBuilder $builder);
}

View File

@ -186,7 +186,7 @@ class NodeBuilder implements NodeParentInterface
*/
public function append(NodeDefinition $node)
{
if ($node instanceof ParentNodeDefinitionInterface) {
if ($node instanceof BuilderAwareInterface) {
$builder = clone $this;
$builder->setParent(null);
$node->setBuilder($builder);

View File

@ -16,11 +16,9 @@ namespace Symfony\Component\Config\Definition\Builder;
*
* @author Victor Berchet <victor@suumit.com>
*/
interface ParentNodeDefinitionInterface
interface ParentNodeDefinitionInterface extends BuilderAwareInterface
{
public function children();
public function append(NodeDefinition $node);
public function setBuilder(NodeBuilder $builder);
}