NodeImportService
class NodeImportService (View source)
Service for importing nodes from an XML structure into the content repository
Internally, uses associative arrays instead of Domain Models for performance reasons, so "nodeData" in this class is always an associative array.
Constants
SUPPORTED_FORMAT_VERSION |
|
Properties
protected PersistenceManagerInterface | $persistenceManager | ||
protected PropertyMapper | $propertyMapper | ||
protected EntityManagerInterface | $entityManager | Doctrine's Entity Manager. |
|
protected Context | $securityContext | ||
protected ImportExportPropertyMappingConfiguration | $propertyMappingConfiguration | ||
protected array | $nodeDataStack | ||
protected array | $nodeIdentifierStack | ||
protected array | $nodeNameStack | ||
protected array | $nodeDataPropertyNames | the list of property names of NodeData. These are the keys inside the nodeData array which is built as intermediate representation while parsing the XML. |
Methods
Determines the ContentRepository format version of the given xml
Imports the sub-tree from the xml reader into the given target path.
Parses the given XML element and adds its content to the internal content tree
Parses the content of the dimensions-tag and returns the dimensions as an array 'dimension name' => dimension value
Parses the content of exported array and returns the values
Parses the content of the properties-tag and returns the properties as an array 'property name' => property value
Convert an element to the value it represents.
Checks if a propertyValue contains an entity and persists it.
Provides the path for a NodeData according to the current stacks
Provides the parent of the given path
Saves the given array as a node data entity without using the ORM.
Details
void
import(XMLReader $xmlReader, string $targetPath, string $resourceLoadPath = null)
Imports the sub-tree from the xml reader into the given target path.
The root node of the imported tree becomes a child of the node specified as the target path, as the following example illustrates:
-
Existing Nodes Before Import:
path
- to
-
- my
-
-
- targetNode
-
-
-
-
- A
-
-
- other
-
- nodes
-
Sub-tree in xml to import to 'path/to/my/targetNode':
-
-
existing nodes after the import:
path
- to
-
- my
-
-
- targetNode
-
-
-
-
- A
-
-
-
-
-
- B
-
-
-
-
-
-
- B1
-
-
-
- another
-
- sub-tree
protected null|string
determineFormatVersion(XMLReader $xmlReader)
Determines the ContentRepository format version of the given xml
protected void
importSubtree(XMLReader $xmlReader)
Imports the sub-tree from the xml reader into the given target path.
The root node of the imported tree becomes a child of the node specified by target path.
This parser uses the depth-first reading strategy, which means it will read the input from top til bottom.
protected void
parseElement(XMLReader $xmlReader)
Parses the given XML element and adds its content to the internal content tree
protected array
parseDimensionsElement(XMLReader $reader)
Parses the content of the dimensions-tag and returns the dimensions as an array 'dimension name' => dimension value
protected array
parseArrayElements(XMLReader $reader, string $elementName, string $currentNodeIdentifier)
Parses the content of exported array and returns the values
protected array
parsePropertiesElement(XMLReader $reader, string $currentNodeIdentifier)
Parses the content of the properties-tag and returns the properties as an array 'property name' => property value
protected mixed
convertElementToValue(XMLReader $reader, string $currentType, string $currentEncoding, string $currentClassName, string $currentNodeIdentifier, string $currentProperty)
Convert an element to the value it represents.
protected void
persistEntities(mixed $propertyValue)
Checks if a propertyValue contains an entity and persists it.
protected void
parseEndElement(XMLReader $reader)
Parses the closing tags writes data to the database then
protected string
getCurrentPath()
Provides the path for a NodeData according to the current stacks
protected string
getParentPath(string $path)
Provides the parent of the given path
protected void
persistNodeData(array $nodeData)
Saves the given array as a node data entity without using the ORM.
If the node data already exists (same dimensions, same identifier, same workspace) it is replaced.