Neos\ContentRepository\Domain\Service\ImportExport\NodeImportService::parseElement PHP Method

parseElement() protected method

Parses the given XML element and adds its content to the internal content tree
protected parseElement ( XMLReader $xmlReader ) : void
$xmlReader XMLReader The XML Reader with the element to be parsed as its root
return void
    protected function parseElement(\XMLReader $xmlReader)
    {
        $elementName = $xmlReader->name;
        switch ($elementName) {
            case 'node':
                // update current node identifier
                $this->nodeIdentifierStack[] = $xmlReader->getAttribute('identifier');
                // update current path
                $nodeName = $xmlReader->getAttribute('nodeName');
                if ($nodeName !== '/') {
                    $this->nodeNameStack[] = Utility::renderValidNodeName($nodeName);
                }
                break;
            case 'variant':
                $path = $this->getCurrentPath();
                $parentPath = $this->getParentPath($path);
                $now = new Now();
                $currentNodeIdentifier = $this->nodeIdentifierStack[count($this->nodeIdentifierStack) - 1];
                $this->nodeDataStack[] = array('Persistence_Object_Identifier' => Algorithms::generateUUID(), 'identifier' => $currentNodeIdentifier, 'nodeType' => $xmlReader->getAttribute('nodeType'), 'workspace' => $xmlReader->getAttribute('workspace'), 'sortingIndex' => $xmlReader->getAttribute('sortingIndex'), 'version' => $xmlReader->getAttribute('version'), 'removed' => (bool) $xmlReader->getAttribute('removed'), 'hidden' => (bool) $xmlReader->getAttribute('hidden'), 'hiddenInIndex' => (bool) $xmlReader->getAttribute('hiddenInIndex'), 'path' => $path, 'pathHash' => md5($path), 'parentPath' => $parentPath, 'parentPathHash' => md5($parentPath), 'properties' => array(), 'accessRoles' => array(), 'creationDateTime' => $now, 'lastModificationDateTime' => $now, 'dimensionValues' => array());
                break;
            case 'dimensions':
                $this->nodeDataStack[count($this->nodeDataStack) - 1]['dimensionValues'] = $this->parseDimensionsElement($xmlReader);
                break;
            case 'properties':
                $currentNodeIdentifier = $this->nodeDataStack[count($this->nodeDataStack) - 1]['identifier'];
                $this->nodeDataStack[count($this->nodeDataStack) - 1][$elementName] = $this->parsePropertiesElement($xmlReader, $currentNodeIdentifier);
                break;
            case 'accessRoles':
                $currentNodeIdentifier = $this->nodeDataStack[count($this->nodeDataStack) - 1]['identifier'];
                $this->nodeDataStack[count($this->nodeDataStack) - 1][$elementName] = $this->parseArrayElements($xmlReader, 'accessRoles', $currentNodeIdentifier);
                break;
            case 'hiddenBeforeDateTime':
            case 'hiddenAfterDateTime':
            case 'creationDateTime':
            case 'lastModificationDateTime':
            case 'lastPublicationDateTime':
                $stringValue = trim($xmlReader->readString());
                $dateValue = $this->propertyMapper->convert($stringValue, 'DateTime', $this->propertyMappingConfiguration);
                $this->nodeDataStack[count($this->nodeDataStack) - 1][$elementName] = $dateValue;
                break;
            default:
                throw new ImportException(sprintf('Unexpected element <%s> ', $elementName), 1423578065);
                break;
        }
    }