eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\PageConverter::restoreBlockFromXml PHP Method

restoreBlockFromXml() protected method

Restores value for a given Block $node.
protected restoreBlockFromXml ( DOMElement $node ) : Block
$node DOMElement
return eZ\Publish\Core\FieldType\Page\Parts\Block
    protected function restoreBlockFromXml(DOMElement $node)
    {
        $blockId = null;
        $items = array();
        $rotation = null;
        $customAttributes = null;
        $attributes = array();
        $name = null;
        $type = null;
        $view = null;
        $overflowId = null;
        $action = null;
        $zoneId = null;
        if ($node->hasAttributes()) {
            foreach ($node->attributes as $attr) {
                switch ($attr->name) {
                    case 'id':
                        // Stored Id has following format : id_<blockId>, so extract <blockId>
                        $blockId = substr($attr->value, strpos($attr->value, '_') + 1);
                        break;
                    case 'action':
                        $action = $attr->value;
                        break;
                    default:
                        $attributes[$attr->name] = $attr->value;
                }
            }
        }
        foreach ($node->childNodes as $node) {
            if ($node->nodeType !== XML_ELEMENT_NODE) {
                continue;
            }
            switch ($node->nodeName) {
                case 'item':
                    $items[] = $this->restoreItemFromXml($node);
                    break;
                case 'rotation':
                    if ($rotation === null) {
                        $rotation = array();
                    }
                    foreach ($node->childNodes as $subNode) {
                        if ($subNode->nodeType !== XML_ELEMENT_NODE) {
                            continue;
                        }
                        $rotation[$subNode->nodeName] = $subNode->nodeValue;
                    }
                    break;
                case 'custom_attributes':
                    if ($customAttributes === null) {
                        $customAttributes = array();
                    }
                    foreach ($node->childNodes as $subNode) {
                        if ($subNode->nodeType !== XML_ELEMENT_NODE) {
                            continue;
                        }
                        $customAttributes[$subNode->nodeName] = $subNode->nodeValue;
                    }
                    break;
                case 'name':
                case 'type':
                case 'view':
                    ${$node->nodeName} = $node->nodeValue;
                    break;
                case 'overflow_id':
                    $overflowId = $node->nodeValue;
                    break;
                case 'zone_id':
                    $zoneId = $node->nodeValue;
                    break;
                default:
                    $attributes[$node->nodeName] = $node->nodeValue;
            }
        }
        return new Parts\Block(array('id' => $blockId, 'action' => $action, 'items' => $items, 'rotation' => $rotation, 'customAttributes' => $customAttributes, 'attributes' => $attributes, 'name' => $name, 'type' => $type, 'view' => $view, 'overflowId' => $overflowId, 'zoneId' => $zoneId));
    }