addExtraFormTypesNode.

@return ArrayNodeDefinition|NodeDefinition
506541
protected function addExtraFormTypesNode()
    {
        $builder = new TreeBuilder();
        $node = $builder->root('types');

        $node
            ->defaultValue(array())
            ->useAttributeAsKey('id')
            ->prototype('array')
                ->children()
                    ->scalarNode('parent')->defaultNull()->end()
                    ->scalarNode('form_type')->isRequired()->end()
                    ->booleanNode('abstract')->defaultFalse()->end()
                    ->scalarNode('description')->defaultNull()->end()
                    ->scalarNode('icon')->defaultNull()->end()
                    ->arrayNode('extra_form_options')
                        ->defaultValue(array())
                        ->useAttributeAsKey('id')
                        ->prototype('array')
                            ->children()
                                ->scalarNode('extra_form_type')->isRequired()->end()
                                ->arrayNode('options')
                                    ->defaultValue(array())->useAttributeAsKey('id')->prototype('variable')->end()
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ;

        return $node;
    }
501093
private function interfaceDeclaration() {
    $node = new InterfaceNode();
    $this->matchDocComment($node);
    $this->mustMatch(T_INTERFACE, $node);
    $name_node = new NameNode();
    $this->mustMatch(T_STRING, $name_node, NULL, TRUE);
    $node->addChild($name_node, 'name');
    if ($this->tryMatch(T_EXTENDS, $node)) {
      $extends = new CommaListNode();
      do {
        $extends->addChild($this->name());
      } while ($this->tryMatch(',', $extends));
      $node->addChild($extends, 'extends');
    }
    $this->matchHidden($node);
    $statement_block = new StatementBlockNode();
    $this->mustMatch('{', $statement_block, NULL, FALSE, TRUE);
    while ($this->currentType !== NULL && $this->currentType !== '}') {
      $this->matchHidden($statement_block);
      if ($this->currentType === T_CONST) {
        $statement_block->addChild($this->_const());
      }
      else {
        $statement_block->addChild($this->interfaceMethod());
      }
    }
    $this->mustMatch('}', $statement_block, NULL, TRUE, TRUE);
    $node->addChild($statement_block, 'statements');
    return $node;
  }
1208403
protected function addTasksNode()
    {
        $builder = new TreeBuilder();
        $node    = $builder->root('tasks');

        $node
            ->isRequired()
            ->requiresAtLeastOneElement()
            ->useAttributeAsKey('task')
            ->prototype('array')
                ->children()
                    ->scalarNode('description')->defaultNull()->end()
                    ->arrayNode('requires')
                        ->useAttributeAsKey('task')
                        ->prototype('scalar')->end()
                    ->end()
                    ->append($this->addCommandsNode())
                ->end()
            ->end();

        return $node;
    }
733397
protected void addMethodNodes(String desc) {
        Type[] args = Type.getArgumentTypes(desc);
        Type ret = Type.getReturnType(desc);
        Node currentNode = this.currentNode;
        Element tmp = doc.createElementNS(XML_URI,"arguments");
        currentNode.appendChild(tmp);
        this.currentNode = tmp;
        for (int i = 0; i < args.length; i++)
            addTypeNode(args[i]);
        tmp = doc.createElementNS(XML_URI,"return");
        currentNode.appendChild(tmp);
        this.currentNode = tmp;
        addTypeNode(ret);
        this.currentNode = currentNode;
    }
    
    /**
     * Add a type node for the specified descriptor.
     *
     * @param desc A type descriptor.
     */
    protected void addTypeNode(String desc) {
        addTypeNode(Type.getType(desc));
    }
    
    /**
     * Add a type node for the specified type.
     * This writes out a &lt;type&gt; node with attributes describing
     * the type.
     *
     * @param type The type to describe.
     */
    protected void addTypeNode(Type type) {
        Element tmp = doc.createElementNS(XML_URI, "type");
        currentNode.appendChild(tmp);
        int i = type.getSort();
        if (i == Type.ARRAY) {
            tmp.setAttribute( "array", "yes");
            tmp.setAttribute( "dimensions",
                              "" + type.getDimensions());
            type = type.getElementType();
            i = type.getSort();
        }
        switch (i) {
        case Type.BOOLEAN:
            tmp.setAttribute( "primitive", "yes");
            tmp.setAttribute( "name", "boolean");
            break;
        case Type.BYTE:
            tmp.setAttribute( "primitive", "yes");
            tmp.setAttribute( "name", "byte");
            break;
        case Type.CHAR:
            tmp.setAttribute( "primitive", "yes");
            tmp.setAttribute( "name", "char");
            break;
        case Type.DOUBLE:
            tmp.setAttribute( "primitive", "yes");
            tmp.setAttribute( "name", "double");
            break;
        case Type.FLOAT:
            tmp.setAttribute( "primitive", "yes");
            tmp.setAttribute( "name", "float");
            break;
        case Type.INT:
            tmp.setAttribute( "primitive", "yes");
            tmp.setAttribute( "name", "int");
            break;
        case Type.LONG:
            tmp.setAttribute( "primitive", "yes");
            tmp.setAttribute( "name", "long");
            break;
        case Type.OBJECT:
            tmp.setAttribute( "name", type.getInternalName());
            break;
        case Type.SHORT:
            tmp.setAttribute( "primitive", "yes");
            tmp.setAttribute( "name", "short");
            break;
        case Type.VOID:
            tmp.setAttribute( "primitive", "yes");
            tmp.setAttribute( "name", "void");
            break;
        }
    }
}
1090801
private function addDbalSection(ArrayNodeDefinition $node)
    {
        $node
            ->children()
            ->arrayNode('dbal')
                ->beforeNormalization()
                    ->ifTrue(static function ($v) {
                        return is_array($v) && ! array_key_exists('connections', $v) && ! array_key_exists('connection', $v);
                    })
                    ->then(static function ($v) {
                        // Key that should not be rewritten to the connection config
                        $excludedKeys = ['default_connection' => true, 'types' => true, 'type' => true];
                        $connection   = [];
                        foreach ($v as $key => $value) {
                            if (isset($excludedKeys[$key])) {
                                continue;
                            }
                            $connection[$key] = $v[$key];
                            unset($v[$key]);
                        }
                        $v['default_connection'] = isset($v['default_connection']) ? (string) $v['default_connection'] : 'default';
                        $v['connections']        = [$v['default_connection'] => $connection];

                        return $v;
                    })
                ->end()
                ->children()
                    ->scalarNode('default_connection')->end()
                ->end()
                ->fixXmlConfig('type')
                ->children()
                    ->arrayNode('types')
                        ->useAttributeAsKey('name')
                        ->prototype('array')
                            ->beforeNormalization()
                                ->ifString()
                                ->then(static function ($v) {
                                    return ['class' => $v];
                                })
                            ->end()
                            ->children()
                                ->scalarNode('class')->isRequired()->end()
                                ->booleanNode('commented')->defaultNull()->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
                ->fixXmlConfig('connection')
                ->append($this->getDbalConnectionsNode())
            ->end();
    }
1270128
protected function lexVariableDefinition(): VariableDefinitionNode
    {
        $start = $this->lexer->getToken();

        /**
         * @return TypeNodeInterface
         */
        $parseType = function (): TypeNodeInterface {
            $this->expect(TokenKindEnum::COLON);
            return $this->lexType();
        };

        return new VariableDefinitionNode(
            $this->lexVariable(),
            $parseType(),
            $this->skip(TokenKindEnum::EQUALS)
                ? $this->lexValue(true)
                : null,
            $this->createLocation($start)
        );
    }
986692
private function addFileSystemNode()
    {
        $builder = new TreeBuilder();
        $node = $builder->root('file_system');

        $node
            ->addDefaultsIfNotSet()
            ->children()
                ->scalarNode('directory')->defaultValue('%sulu.cache_dir%/preview')->end()
                ->scalarNode('extension')->defaultNull()->end()
                ->integerNode('umask')->defaultValue(0002)->end()
            ->end();

        return $node;
    }
596181
protected function lexOperationTypeDefinition(): OperationTypeDefinitionNode
    {
        $start = $this->lexer->getToken();

        $operation = $this->lexOperationType();

        $this->expect(TokenKindEnum::COLON);

        return new OperationTypeDefinitionNode(
            $operation,
            $this->lexNamedType(),
            $this->createLocation($start)
        );
    }
1324358
protected function generateNodeTypeDefinitions()
    {
        $code = '';
        /** @var NodeType $nodeType */
        foreach ($this->nodeTypeManager->getNodeTypes(false) as $nodeType) {
            $code .= $this->generateFusionForNodeType($nodeType);
        }
        return $code;
    }
184935
private function addChainNode()
    {
        $builder = new TreeBuilder('chain');
        $node    = $this->getRootNode($builder, 'chain');

        $node
            ->fixXmlConfig('provider')
            ->children()
                ->arrayNode('providers')
                    ->prototype('scalar')->end()
                ->end()
            ->end()
        ;

        return $node;
    }
579413
public function addNodeType(NodeTypeContract $nodeType)
    {
        if ( ! $this->hasNodeType($nodeType->getKey()))
        {
            $this->put($nodeType->getKey(), $nodeType);
        }
    }
131655
protected function getDataGridConfigTreeBuilder(): NodeDefinition
    {
        $builder = new TreeBuilder();
        $node = $builder->root('configurations');
        $dataGridDefinition = $node
            ->useAttributeAsKey('code')
            ->prototype('array')
            ->performNoDeepMerging()
            ->children();

        $this->appendDataGridDefinition($dataGridDefinition);

        $dataGridDefinition
            ->end()
            ->end()
            ->end();

        return $node;
    }
530916
private function createClassesNodeDefinition()
    {
        $classesNode = new ArrayNodeDefinition('classes');

        $classesNode
            ->addDefaultsIfNotSet()
            ->children()
                ->scalarNode('process_handler')
                    ->defaultValue('Lexik\Bundle\WorkflowBundle\Handler\ProcessHandler')
                ->end()
                ->scalarNode('process')
                    ->defaultValue('Lexik\Bundle\WorkflowBundle\Flow\Process')
                ->end()
                ->scalarNode('step')
                    ->defaultValue('Lexik\Bundle\WorkflowBundle\Flow\Step')
                ->end()
            ->end()
        ;

        return $classesNode;
    }
143236
protected function add()
    {
        $nodeRef = $this->buildCmsNodeRef($slugKey = null);

        if (!$this->buttonPushed()) {

            $node = $nodeRef->generateNode();
            $node->setNodePartials(new NodePartials('all', 'fields', 'fields'));

            $this->NodeMapper->defaultsOnNode($node);

            $this->NodeBinder->bindPersistentFields($node, $this->getErrors(), $this->params, $this->rawParams);
            $this->NodeBinder->fireAddBindEvents($node, $this->getErrors(), $this->params, $this->rawParams);

            $location = 'load';
            $this->Events->trigger('NodeCmsController.add'.'.'.$location, $this->errors, $this->templateVars, $node);
            foreach ((array)$nodeRef->getElement()->getAspects() as $aspect)
                $this->Events->trigger('NodeCmsController.@'.$aspect->Slug.'.'.'add'.'.'.$location, $this->errors, $this->templateVars, $node);

            if($node->hasTitle() && !$node->hasSlug())
                $node->Slug = SlugUtils::createSlug($node->Title, $node->getNodeRef()->getElement()->AllowSlugSlashes);

            $this->bindNodeToActionDatasource($node);

            //show form view (action_form_view)
            return new View($this->formView());

            //*** at this point the only subsequent actions will result from button presses
        }

        if ($this->cancelButtonPushed() || $this->deleteConfirmButtonPushed()) {

            // $this->service->delete($id);

            $view = new View($this->cancelView());

            $location = 'cancel';
            $this->Events->trigger('NodeCmsController.add'.'.'.$location,
                                    $this->errors, $this->templateVars, $view);
            foreach ((array)$nodeRef->getElement()->getAspects() as $aspect)
                $this->Events->trigger('NodeCmsController.@'.$aspect->Slug.'.'.'add'.'.'.$location,
                                        $this->errors, $this->templateVars, $view);

            //redirect to pages list (action_cancel_view)
            return $view;
        }

        if ($this->saveButtonPushed() || $this->saveAndContinueButtonPushed() || $this->saveAndNewButtonPushed()) {

            //get default form backing object
            // $page = $this->service->getByID($id);
            try {
                $nodeRef = $this->buildCmsNodeRef($slugKey = 'Slug');

                $node = $nodeRef->generateNode();

                //bind posted params to form backing object
                $this->NodeBinder->bindPersistentFields($node, $this->getErrors(), $this->params, $this->rawParams);
                $this->NodeBinder->fireAddBindEvents($node, $this->getErrors(), $this->params, $this->rawParams);

                //FIRE EVENTS FOR PRE-ADD
                $location = 'pre';
                $this->Events->trigger('NodeCmsController.add'.'.'.$location,
                                        $this->errors, $this->templateVars, $node);
                foreach((array)$nodeRef->getElement()->getAspects() as $aspect)
                    $this->Events->trigger('NodeCmsController.@'.$aspect->Slug.'.'.'add'.'.'.$location,
                                            $this->errors, $this->templateVars, $node);

                // check permissions
                // $this->checkAddPermission($node);
                $this->checkNonce();

                $this->getErrors()->throwOnError();

                $this->RegulatedNodeService->add($node);

                $location = 'post';
                $this->Events->trigger('NodeCmsController.add'.'.'.$location,
                                            $this->errors, $this->templateVars, $node);
                foreach((array)$nodeRef->getElement()->getAspects() as $aspect)
                    $this->Events->trigger('NodeCmsController.@'.$aspect->Slug.'.'.'add'.'.'.$location,
                                            $this->errors, $this->templateVars, $node);


            } catch(ValidationException $ve) {
                $location = 'validationException';
                $this->Events->trigger('NodeCmsController.add'.'.'.$location,
                                            $this->errors, $this->templateVars, $node);
                foreach ((array)$nodeRef->getElement()->getAspects() as $aspect)
                    $this->Events->trigger('NodeCmsController.@'.$aspect->Slug.'.'.'add'.'.'.$location,
                                            $this->errors, $this->templateVars, $node);

                $this->RegulatedNodeService->resolveLinkedNodes($node, $node->getNodePartials(), true);

                //bind form backing object to datasource
                $this->bindNodeToActionDatasource($node);

                //re-throw validationexception, which shows form view
                throw $ve;
            } catch (Exception $e) {

                $this->ErrorHandler->sendErrorEmail($e);

                $this->errors->addGlobalError($e->getCode(), $e->getMessage());

                if(!empty($node))
                {
                    $location = 'validationException';
                    $this->Events->trigger('NodeCmsController.add'.'.'.$location,
                                                $this->errors, $this->templateVars, $node);

                    foreach((array)$nodeRef->getElement()->getAspects() as $aspect)
                        $this->Events->trigger('NodeCmsController.@'.$aspect->Slug.'.'.'add'.'.'.$location,
                                                $this->errors, $this->templateVars, $node);

                    $this->RegulatedNodeService->resolveLinkedNodes($node, $node->getNodePartials(), true);

                    //bind form backing object to datasource
                    $this->bindNodeToActionDatasource($node);
                }

                //re-throw validationexception, which shows form view
                throw new ValidationException($this->errors);
            }

            $this->Session->setFlashAttribute('saved', true);

            if ($this->saveButtonPushed())
                //redirect to list (action_success_view)
                return new View($this->successView());

            elseif($this->saveAndContinueButtonPushed())
                //redirect to edit (action_continue_view)
                return new View($this->continueView(), array('slug'=> $node->getSlug()));

            elseif($this->saveAndNewButtonPushed())
                // redirect to new edit (action_new_view)
                return new View($this->newView(true), array('newslug'=> $node->getSlug()));

        }

        throw new Exception("unsupported button for this action");
    }
365308
protected function lexEnumTypeExtension(): EnumTypeExtensionNode
    {
        $start = $this->lexer->getToken();

        $this->expectKeyword(KeywordEnum::EXTEND);
        $this->expectKeyword(KeywordEnum::ENUM);

        $name       = $this->lexName();
        $directives = $this->lexDirectives();
        $values     = $this->lexEnumValuesDefinition();

        if (empty($directives) && empty($values)) {
            throw $this->unexpected();
        }

        return new EnumTypeExtensionNode($name, $directives, $values, $this->createLocation($start));
    }
275503
protected function addConfigParameterNode()
    {
    	$builder = new TreeBuilder();
    	$node = $builder->root('config');
    
    	$node
    		->treatTrueLike(array('form' => array(
    			'type' => "ASF\WebsiteBundle\Form\Type\ConfigType",
    			'name' => 'website_config_type'
    		)))
    		->treatFalseLike(array('form' => array(
    			'type' => "ASF\WebsiteBundle\Form\Type\ConfigType",
    			'name' => 'website_config_type'
    		)))
    		->addDefaultsIfNotSet()
    		->children()
    			->arrayNode('form')
    				->addDefaultsIfNotSet()
    				->children()
    					->scalarNode('type')
    						->defaultValue('ASF\WebsiteBundle\Form\Type\ConfigType')
    					->end()
    					->scalarNode('name')
    						->defaultValue('website_config_type')
    					->end()
    					->arrayNode('validation_groups')
    						->prototype('scalar')->end()
    						->defaultValue(array("Default"))
    					->end()
    				->end()
    			->end()
    		->end()
    	;
    
    	return $node;
    }
258427
private function addCustomProviderNode()
    {
        $builder = new TreeBuilder('custom_provider');
        $node    = $this->getRootNode($builder, 'custom_provider');

        $node
            ->children()
                ->scalarNode('type')->isRequired()->cannotBeEmpty()->end()
                ->arrayNode('options')
                    ->useAttributeAsKey('name')
                    ->prototype('scalar')->end()
                ->end()
            ->end()
        ;

        return $node;
    }