Appends a node definition.

Usage:

$node = new ArrayNodeDefinition('name')
->children()
->scalarNode('foo')->end()
->scalarNode('baz')->end()
->append($this->getBarNodeDefinition())
->end()
;

@return $this
540558
public function append(NodeDefinition $node)
    {
        if ($node instanceof ParentNodeDefinitionInterface) {
            $builder = clone $this;
            $builder->setParent(null);
            $node->setBuilder($builder);
        }

        if (null !== $this->parent) {
            $this->parent->append($node);
            // Make this builder the node parent to allow for a fluid interface
            $node->setParent($this);
        }

        return $this;
    }
914538
public function addChild(Node $node) : self
    {
        $node->setParent($this);
        $this->children[] = $node;

        return $this;
    }
657961
private function createStepsNodeDefinition()
    {
        $stepsNode = new ArrayNodeDefinition('steps');

        $stepsNode
            ->defaultValue(array())
            ->useAttributeAsKey('name')
            ->prototype('array')
                ->addDefaultsIfNotSet()
                ->children()
                    ->scalarNode('label')
                        ->defaultValue('')
                    ->end()

                    ->arrayNode('roles')
                        ->prototype('scalar')->end()
                    ->end()

                    ->arrayNode('model_status')
                        ->validate()
                            ->ifTrue(function ($value) {
                                return (is_array($value) && count($value) < 2);
                            })
                            ->thenInvalid('You must specify an array with [ method, constant ]')
                            ->ifTrue(function ($value) {
                                return ( ! defined($value[1]));
                            })
                            ->thenInvalid('You must specify a valid constant name as second parameter')
                        ->end()
                        ->prototype('scalar')->end()
                    ->end()

                    ->scalarNode('on_invalid')
                        ->defaultNull()
                    ->end()
                ->end()
                ->append($this->createNextStatesNodeDefinition())
            ->end()
        ;

        return $stepsNode;
    }
48285
protected function _declareNode()
    {
        $this->_codeNode();
        $body = $this->_stream->current() . $this->_stream->next([';', '{']);

        if (preg_match('~ticks~i', $body, $matches)) {
            $isBlock = substr($body, -1) === '{';
            if ($isBlock) {
                $body = substr($body, 0, -1);
            }
            $node = new NodeDef($body, 'declare');
            $this->_contextualize($node);

            if ($isBlock) {
                $this->_states['body'] .= '{';
                $this->_states['current'] = $this->_codeNode();
            }
            return $node;
        }
        $this->_states['body'] .= $body;
        $node = new BlockDef($body, 'declare');
        $node->hasMethods = false;
        $this->_states['current'] = $this->_root;
        $this->_contextualize($node);
        return $this->_states['current'] = $node;
    }
750587
public function appendConfiguration(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->children()
                ->arrayNode('vcs')
                    ->children()
                        ->scalarNode('url')->end()
                        ->arrayNode('export')
                            ->children()
                                ->scalarNode('revfile')->isRequired()->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ;
    }
714302
private function getFormNode(): NodeDefinition
    {
        $treeBuilder = new TreeBuilder('form');

        return $treeBuilder
            ->getRootNode()
            ->addDefaultsIfNotSet()
            ->children()
                ->scalarNode('novalidate')
                    ->info('Information if HTML5 inline validation is disabled')
                    ->defaultFalse()
                ->end()
            ->end()
        ;
    }
1026069
def append(node)
      if node.is_a?(EndTag)
        return if empty_tag?(node.name)
        po = @pos
        while po.parent and po.name != node.name
          po = po.parent
        end
        if po.name == node.name
          @pos = po.parent
        end
      else
        rexml = to_rexml(node)

        # if node is second root element, add root element wrap html tag
        if rexml.is_a?(REXML::Element) and @pos == @doc and @doc.root
          if @doc.root.name != 'html'
            html = REXML::Element.new
            html.name = "html"
            i = @doc.root.index_in_parent-1
            while pos = @doc.delete_at(i)
              @doc.delete_element(pos) if pos.is_a?(REXML::Element)
              html << pos
            end
            @doc << html
            @pos = html
          end
          @pos = @doc.root
        end
        @pos << rexml
        if rexml.is_a?(REXML::Element) and !empty_tag?(node.name) and !node.empty?
          @pos = rexml
        end
      end
    end
1273021
protected function prependChild(Node $node) {
    if ($this->head === NULL) {
      $this->childCount++;
      $node->parent = $this;
      $node->previous = NULL;
      $node->next = NULL;
      $this->head = $this->tail = $node;
    }
    else {
      $this->insertBeforeChild($this->head, $node);
      $this->head = $node;
    }
    return $this;
  }
68683
def add(self, node):
        """"""
        if not isinstance(node, Node):
            raise TypeError()
        for i, j in enumerate(self.__nodes):
            if j.node_id == node.node_id:
                self.__nodes[i] = node
                return
        self.__nodes.append(node)
639810
protected function instantiateNode()
    {
        return new IntegerNode($this->name, $this->parent, $this->min, $this->max, $this->pathSeparator);
    }
854154
private function addObjectsSection(ArrayNodeDefinition $node)
    {
        $node
            ->children()
                ->arrayNode('objects')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->arrayNode('contact')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('model')->defaultValue(Contact::class)->end()
                                ->scalarNode('repository')->defaultValue(ContactRepository::class)->end()
                            ->end()
                        ->end()
                        ->arrayNode('account')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('model')->defaultValue(Account::class)->end()
                                ->scalarNode('repository')->defaultValue(AccountRepository::class)->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end();
    }
988932
private function createNextStatesNodeDefinition()
    {
        $flowTypes = array(
            NextStateInterface::TYPE_STEP,
            NextStateInterface::TYPE_STEP_OR,
            NextStateInterface::TYPE_PROCESS,
        );

        $nextStatesNode = new ArrayNodeDefinition('next_states');

        $nextStatesNode
            ->useAttributeAsKey('name')
            ->prototype('array')
                ->addDefaultsIfNotSet()
                ->children()
                    ->scalarNode('type')
                        ->defaultValue('step')
                        ->validate()
                             ->ifNotInArray($flowTypes)
                             ->thenInvalid('Invalid next element type "%s". Please use one of the following types: '.implode(', ', $flowTypes))
                        ->end()
                    ->end()

                    ->variableNode('target')
                        ->cannotBeEmpty()
                    ->end()
                ->end()
            ->end()
        ;

        return $nextStatesNode;
    }
550303
public function leaveNode(Node $node)
    {
        if ($node instanceof Stmt\Class_
            || $node instanceof Stmt\Interface_
            || $node instanceof Stmt\Trait_
        ) {
            if (empty($this->suffix) && !empty($this->namespaceNode)) {
                $node->name = $this->append(new Name($node->name), $this->namespaceNode);
            }
            else {
                $node->name = $node->name . $this->suffix;
            }
        } elseif ($node instanceof Name) {
            if (!$this->cancelNext) {
                return $this->appendSuffix($node);
            }
            $this->cancelNext = false;
        } elseif ($node instanceof Stmt\Use_) {
            $this->isImport = false;
        } elseif ($node instanceof Stmt\GroupUse) {
            $this->groupImport = false;
        }
    }
682712
private function addEditorSection(ArrayNodeDefinition $node)
    {
        /** @noinspection PhpUndefinedMethodInspection */
        $node
            ->children()
                ->arrayNode('editor')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('template')->defaultValue('@EkynaCms/Editor/content.html.twig')->end()
                        ->scalarNode('css_path')->defaultValue('/bundles/ekynacms/css/editor-document.css')->end()
                        ->arrayNode('viewports')
                            ->defaultValue(Editor::getDefaultViewportsConfig())
                            ->requiresAtLeastOneElement()
                            ->useAttributeAsKey('name')
                            ->prototype('array')
                                ->children()
                                    ->integerNode('width')->isRequired()->min(0)->defaultValue(0)->end()
                                    ->integerNode('height')->isRequired()->min(0)->defaultValue(0)->end()
                                    ->scalarNode('icon')->isRequired()->cannotBeEmpty()->end()
                                    ->scalarNode('title')->isRequired()->cannotBeEmpty()->end()
                                    ->booleanNode('active')->defaultFalse()->end()
                                ->end()
                            ->end()
                            ->validate()
                            ->ifTrue(function($classes) {
                                if (0 < count(array_diff(Editor::getViewportsKeys(), (array) $classes))) {
                                    return true;
                                }
                                return false;
                            })
                            ->thenInvalid('Unexpected key(s) in editor classes configuration.')
                            ->end()
                        ->end()
                        ->arrayNode('layout')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('adapter')
                                    ->defaultValue(Bootstrap3Adapter::class)
                                    ->isRequired()->cannotBeEmpty()
                                ->end()
                            ->end()
                        ->end()
                        ->arrayNode('plugins')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->arrayNode('block')
                                    ->addDefaultsIfNotSet()
                                    ->children()
                                        ->scalarNode('default')
                                            ->defaultValue('ekyna_block_tinymce')
                                        ->end()
                                        ->integerNode('min_size')
                                            ->min(1)->max(12)
                                            ->defaultValue(2)
                                        ->end()
                                        ->arrayNode('tinymce')
                                            ->addDefaultsIfNotSet()
                                            ->children()
                                                ->scalarNode('default_content')
                                                    ->defaultValue('<p>Default content.</p>')
                                                ->end()
                                            ->end()
                                        ->end()
                                        ->arrayNode('image')
                                            ->addDefaultsIfNotSet()
                                            ->children()
                                                ->scalarNode('default_path')
                                                    ->defaultValue('/bundles/ekynacms/img/default-image.gif')
                                                ->end()
                                                ->scalarNode('default_alt')
                                                    ->defaultValue('Default image')
                                                ->end()
                                                ->scalarNode('filter')->defaultValue('cms_block_image')->end()
                                                ->arrayNode('themes')
                                                    ->useAttributeAsKey('name')
                                                    ->prototype('scalar')->end()
                                                    ->defaultValue(PropertyDefaults::getDefaultThemeChoices())
                                                ->end()
                                                ->arrayNode('styles')
                                                    ->useAttributeAsKey('name')
                                                    ->prototype('scalar')->end()
                                                    ->defaultValue(PropertyDefaults::getDefaultStyleChoices())
                                                ->end()
                                                ->arrayNode('animations')
                                                    ->useAttributeAsKey('name')
                                                    ->prototype('scalar')->end()
                                                    ->defaultValue(PropertyDefaults::getDefaultAnimationChoices())
                                                ->end()
                                            ->end()
                                        ->end()
                                        ->arrayNode('video')
                                            ->addDefaultsIfNotSet()
                                            ->children()
                                                ->scalarNode('default_poster')
                                                    ->defaultValue('/bundles/ekynacms/img/default-image.gif')
                                                ->end()
                                            ->end()
                                        ->end()
                                        ->arrayNode('feature')
                                            ->addDefaultsIfNotSet()
                                            ->children()
                                                ->scalarNode('image_filter')->defaultValue('cms_block_feature')->end()
                                                ->arrayNode('animations')
                                                    ->useAttributeAsKey('name')
                                                    ->prototype('scalar')->end()
                                                    ->defaultValue(PropertyDefaults::getDefaultAnimationChoices())
                                                ->end()
                                            ->end()
                                        ->end()
                                        ->arrayNode('template')
                                            ->addDefaultsIfNotSet()
                                            ->children()
                                                ->arrayNode('templates')
                                                    ->defaultValue([])
                                                    ->useAttributeAsKey('name')
                                                    ->prototype('array')
                                                        ->children()
                                                            ->scalarNode('title')->isRequired()->cannotBeEmpty()->end()
                                                            ->scalarNode('path')->isRequired()->cannotBeEmpty()->end()
                                                        ->end()
                                                    ->end()
                                                ->end()
                                            ->end()
                                        ->end()
                                        ->arrayNode('tabs')
                                            ->addDefaultsIfNotSet()
                                            ->children()
                                                ->arrayNode('themes')
                                                    ->useAttributeAsKey('name')
                                                    ->prototype('scalar')->end()
                                                    ->defaultValue(PropertyDefaults::getDefaultThemeChoices())
                                                ->end()
                                            ->end()
                                        ->end()
                                    ->end()
                                ->end()
                                ->arrayNode('container')
                                    ->addDefaultsIfNotSet()
                                    ->children()
                                        ->scalarNode('default')->defaultValue('ekyna_container_background')->end()
                                        ->arrayNode('background')
                                            ->addDefaultsIfNotSet()
                                            ->children()
                                                ->scalarNode('filter')->defaultValue('cms_container_background')->end()
                                                ->scalarNode('default_color')->defaultValue('')->end()
                                                ->arrayNode('themes')
                                                    ->useAttributeAsKey('name')
                                                    ->prototype('scalar')->end()
                                                    ->defaultValue(PropertyDefaults::getDefaultThemeChoices())
                                                ->end()
                                            ->end()
                                        ->end()
                                    ->end()
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ;
    }
806525
protected function appendDescriptionNode()
    {
        if ($this->template) {
            $descriptionTag = $this->getTemplateRegistrationDescriptionTag();
        } else {
            $descriptionTag = $this->getRegistrationDescriptionTag();
        }

        $descriptionElement = $this->dom->createElement($descriptionTag);
        $descriptionElement->setAttribute('xmlns:i', 'http://www.w3.org/2001/XMLSchema-instance');
        $descriptionElement->setAttribute('xmlns', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');

        return $this->content->appendChild($descriptionElement);
    }
89692
private function addObjectsSection(ArrayNodeDefinition $node)
    {
        $node
            ->children()
                ->arrayNode('objects')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->arrayNode('target_group')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('model')
                                    ->defaultValue(TargetGroup::class)
                                ->end()
                                ->scalarNode('repository')
                                    ->defaultValue(TargetGroupRepository::class)
                                ->end()
                            ->end()
                        ->end()
                        ->arrayNode('target_group_condition')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('model')
                                    ->defaultValue(TargetGroupCondition::class)
                                ->end()
                                ->scalarNode('repository')
                                    ->defaultValue(TargetGroupConditionRepository::class)
                                ->end()
                            ->end()
                        ->end()
                        ->arrayNode('target_group_rule')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('model')
                                    ->defaultValue(TargetGroupRule::class)
                                ->end()
                                ->scalarNode('repository')
                                    ->defaultValue(TargetGroupRuleRepository::class)
                                ->end()
                            ->end()
                        ->end()
                        ->arrayNode('target_group_webspace')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('model')
                                    ->defaultValue(TargetGroupWebspace::class)
                                ->end()
                                ->scalarNode('repository')
                                    ->defaultValue(TargetGroupWebspaceRepository::class)
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end();
    }
840301
public function append($source)
    {
        foreach ($this as $node) {
            if ($node instanceof Element) {
                $node->prepend($source);
            }
        }

        return $this;
    }