BlockFactory.php
protected function buildBlocks($rootId)
    {
        // build the root block
        if (!$this->rawLayout->hasProperty($rootId, RawLayout::RESOLVED_OPTIONS, true)) {
            $this->buildBlock($rootId);
        }

        // build child blocks
        $iterator = $this->rawLayout->getHierarchyIterator($rootId);
        foreach ($iterator as $id) {
            if (!$this->rawLayout->has($id) || $this->rawLayout->hasProperty($id, RawLayout::RESOLVED_OPTIONS, true)) {
                // the block is already built
                continue;
            }
            if (!$this->isContainerBlock($iterator->getParent())) {
                $blockType = $this->rawLayout->getProperty($iterator->getParent(), RawLayout::BLOCK_TYPE, true);

                throw new Exception\LogicException(
                    sprintf(
                        'The "%s" item cannot be added as a child to "%s" item (block type: %s) '
                        . 'because only container blocks can have children.',
                        $id,
                        $iterator->getParent(),
                        $blockType instanceof BlockTypeInterface ? $blockType->getName() : $blockType
                    )
                );
            }
            $this->buildBlock($id);
        }

        // apply layout changes were made by built blocks and build newly added blocks
        $this->layoutManipulator->applyChanges($this->context);
        if ($this->layoutManipulator->getNumberOfAddedItems() !== 0) {
            $this->buildBlocks($rootId);
        }
    }
protected function buildBlocks($rootId)
    {
        // build the root block
        if (!$this->rawLayout->hasProperty($rootId, RawLayout::RESOLVED_OPTIONS, true)) {
            $this->buildBlock($rootId);
        }

        // build child blocks
        $iterator = $this->rawLayout->getHierarchyIterator($rootId);
        foreach ($iterator as $id) {
            if (!$this->rawLayout->has($id) || $this->rawLayout->hasProperty($id, RawLayout::RESOLVED_OPTIONS, true)) {
                // the block is already built
                continue;
            }
            if (!$this->isContainerBlock($iterator->getParent())) {
                $blockType = $this->rawLayout->getProperty($iterator->getParent(), RawLayout::BLOCK_TYPE, true);

                throw new Exception\LogicException(
                    sprintf(
                        'The "%s" item cannot be added as a child to "%s" item (block type: %s) '
                        . 'because only container blocks can have children.',
                        $id,
                        $iterator->getParent(),
                        $blockType instanceof BlockTypeInterface ? $blockType->getName() : $blockType
                    )
                );
            }
            $this->buildBlock($id);
        }

        // apply layout changes were made by built blocks and build newly added blocks
        $this->layoutManipulator->applyChanges($this->context);
        if ($this->layoutManipulator->getNumberOfAddedItems() !== 0) {
            $this->buildBlocks($rootId);
        }
    }
protected function buildBlocks ( $ rootId ) { // build the root block if ( ! $ this -> rawLayout -> hasProperty ( $ rootId , RawLayout :: RESOLVED_OPTIONS , true ) ) { $ this -> buildBlock ( $ rootId ) ; } // build child blocks $ iterator = $ this -> rawLayout -> getHierarchyIterator ( $ rootId ) ; foreach ( $ iterator as $ id ) { if ( ! $ this -> rawLayout -> has ( $ id ) || $ this -> rawLayout -> hasProperty ( $ id , RawLayout :: RESOLVED_OPTIONS , true ) ) { // the block is already built continue ; } if ( ! $ this -> isContainerBlock ( $ iterator -> getParent ( ) ) ) { $ blockType = $ this -> rawLayout -> getProperty ( $ iterator -> getParent ( ) , RawLayout :: BLOCK_TYPE , true ) ; throw new Exception \ LogicException ( sprintf ( 'The "%s" item cannot be added as a child to "%s" item (block type: %s) ' . 'because only container blocks can have children.' , $ id , $ iterator -> getParent ( ) , $ blockType instanceof BlockTypeInterface ? $ blockType -> getName ( ) : $ blockType ) ) ; } $ this -> buildBlock ( $ id ) ; } // apply layout changes were made by built blocks and build newly added blocks $ this -> layoutManipulator -> applyChanges ( $ this -> context ) ; if ( $ this -> layoutManipulator -> getNumberOfAddedItems ( ) !== 0 ) { $ this -> buildBlocks ( $ rootId ) ; } }
Builds all blocks starting with and including the given root block

@param string $rootId

@throws Exception\LogicException if a child block is added to not container
Builds all blocks starting with and including the given root block