NodeDataRepository
class NodeDataRepository extends Repository (View source)
A purely internal repository for NodeData storage
DO NOT USE outside the ContentRepository package!
The ContextFactory can be used to create a Context that allows to find Node instances that act as the public API to the ContentRepository.
Constants
POSITION_BEFORE |
Constants for setNewIndex() |
POSITION_AFTER |
|
POSITION_LAST |
|
INDEX_MAXIMUM |
Maximum possible index |
Properties
protected SplObjectStorage | $addedNodes | ||
protected SplObjectStorage | $removedNodes | ||
protected EntityManagerInterface | $entityManager | Doctrine's Entity Manager. |
|
protected NodeTypeManager | $nodeTypeManager | ||
protected LoggerInterface | $systemLogger | ||
protected NodeFactory | $nodeFactory | ||
protected Context | $securityContext | ||
protected array | $highestIndexCache | ||
protected array | $defaultOrderings |
Methods
Constructor
Adds a NodeData object to this repository.
Removes an object to the persistence.
No description
Find a single node by exact path.
Find a shadow node by exact path
This finds nodes by path and delivers a raw, unfiltered result.
Finds a node by its identifier and workspace.
Find all objects and return an IterableResult
Iterate over an IterableResult and return a Generator
Assigns an index to the given node which reflects the specified position.
Finds recursively nodes by its parent and (optionally) by its node type.
Finds nodes by its parent and (optionally) by its node type.
Internal method
Find NodeData by parent path without any dimension reduction and grouping by identifier
Find NodeData by identifier path without any dimension reduction
Finds nodes by its parent and (optionally) by its node type given a Context
Counts nodes by its parent and (optionally) by its node type.
Make room in the sortindex-index space of a given path in preparation to inserting a node.
Finds the next free index on the level below the given parent path across all workspaces.
No description
Returns the next-lower-index seen from the given reference index in the level below the specified parent path. If no node with a lower than the given index exists at that level, the reference index is returned.
Returns the next-higher-index seen from the given reference index in the level below the specified parent path. If no node with a higher than the given index exists at that level, NULL is returned.
Sorts the given nodes by their index
Finds a single node by its parent and (optionally) by its node type
Finds a single node by its parent and (optionally) by its node type
Finds all nodes of the specified workspace lying on the path specified by (and including) the given starting point and end point and (optionally) a node type filter.
Find nodes by a value in properties
Flushes the addedNodes and removedNodes registry.
Add node type filter constraints to the query builder
Generates a two dimensional array with the filters. First level is: 'excludeNodeTypes' 'includeNodeTypes'
No description
Iterates of the array of objects and removes all those which have recently been removed from the repository, but whose removal has not yet been persisted.
Returns a subset of $nodes which are not flagged as removed.
Returns a subset of $nodes which are flagged as removed.
Persists all entities managed by the repository and all cascading dependencies
Signals that persistEntities() in this repository finished correctly.
If $dimensions is not empty, adds join constraints to the given $queryBuilder limiting the query result to matching hits.
Given an array with duplicate nodes (from different workspaces and dimensions) those are reduced to uniqueness (by node identifier)
Given an array with duplicate nodes (from different workspaces) those are reduced to uniqueness (by node identifier and dimensions hash)
Find all NodeData objects inside a given workspace sorted by path to be used in publishing. The order makes sure that parent nodes are published first.
Find out if the given path exists anywhere in the CR. (internal) If you need this functionality use \Neos\ContentRepository\Domain\Service\NodeService::nodePathExistsInAnyContext()
Find all node data in a path matching the given workspace hierarchy
Searches for possible relations to the given entity identifiers in NodeData.
Searches for possible relations to the given entity identifiers in NodeData using a path prefix.
Remove all nodes below a given path. Does not care about workspaces and dimensions.
Test if a given NodeData is in the set of removed node data objects
No description
No description
No description
No description
No description
Returns an array that contains the given workspace and all base (parent) workspaces of it.
Returns a query builder for a query on node data using the given relation map.
Details
__construct()
Constructor
void
add(object $object)
Adds a NodeData object to this repository.
This repository keeps track of added and removed nodes (additionally to the other Unit of Work) in order to find in-memory nodes.
void
remove(object $object)
Removes an object to the persistence.
This repository keeps track of added and removed nodes (additionally to the other Unit of Work) in order to find in-memory nodes.
findByNodeIdentifier($nodeIdentifier)
No description
NodeData|null
findOneByPath(string $path, Workspace $workspace, array $dimensions = null, bool|null $removedNodes = false)
Find a single node by exact path.
NodeData|null
findShadowNodeByPath(string $path, Workspace $workspace, array $dimensions = null)
Find a shadow node by exact path
protected array
findRawNodesByPath(string $path, Workspace $workspace, array $dimensions = null, bool $onlyShadowNodes = false)
This finds nodes by path and delivers a raw, unfiltered result.
To get a "usable" set of nodes, filtering by workspaces, dimensions and removed nodes must be done on the result.
NodeInterface|null
findOneByPathInContext(string $path, Context $context)
Finds a node by its path and context.
If the node does not exist in the specified context's workspace, this function will try to find one with the given path in one of the base workspaces (if any).
Examples for valid paths:
/ the root node /foo node "foo" on the first level /foo/bar node "bar" on the second level /foo/ first node on second level, below "foo"
NodeData|null
findOneByIdentifier(string $identifier, Workspace $workspace, array $dimensions = null, bool $removedNodes = false)
Finds a node by its identifier and workspace.
If the node does not exist in the specified workspace, this function will try to find one with the given identifier in one of the base workspaces (if any).
IterableResult
findAllIterator()
Find all objects and return an IterableResult
Generator
iterate(IterableResult $iterator, callable $callback = null)
Iterate over an IterableResult and return a Generator
This method is useful for batch processing a huge result set.
void
setNewIndex(NodeData $node, int $position, NodeInterface $referenceNode = null)
Assigns an index to the given node which reflects the specified position.
If the position is "before" or "after", an index will be chosen which makes the given node the previous or next node of the given reference node. If the position "last" is specified, an index higher than any existing index will be chosen.
If no free index is available between two nodes (for "before" and "after"), the whole index of the current node level will be renumbered.
NodeData[]
findByParentAndNodeTypeRecursively(string $parentPath, string $nodeTypeFilter, Workspace $workspace, array $dimensions = null, bool $removedNodes = false)
Finds recursively nodes by its parent and (optionally) by its node type.
NodeData[]
findByParentAndNodeType(string $parentPath, string $nodeTypeFilter, Workspace $workspace, array $dimensions = null, bool $removedNodes = false, bool $recursive = false)
Finds nodes by its parent and (optionally) by its node type.
If the $recursive flag is set to true, all matching nodes underneath $parentPath will be returned
Note: Filters out removed nodes.
The primary sort key is the index, the secondary sort key (if indices are equal, which only occurs in very rare cases) is the identifier.
protected array
getNodeDataForParentAndNodeType(string $parentPath, string $nodeTypeFilter, Workspace $workspace, array $dimensions = null, bool|null $removedNodes = false, bool $recursive = false)
Internal method
NodeData[]
findByParentWithoutReduce(string $parentPath, Workspace $workspace)
Find NodeData by parent path without any dimension reduction and grouping by identifier
Only used internally for setting the path of all child nodes
NodeData[]
findByIdentifierWithoutReduce(string $identifier, Workspace $workspace)
Find NodeData by identifier path without any dimension reduction
Only used internally for finding whether the node exists in another dimension
NodeInterface[]
findByParentAndNodeTypeInContext(string $parentPath, string $nodeTypeFilter, Context $context, bool $recursive = false)
Finds nodes by its parent and (optionally) by its node type given a Context
TODO Move to a new Node operation getDescendantNodes(...)
int
countByParentAndNodeType(string $parentPath, string $nodeTypeFilter, Workspace $workspace, array $dimensions = null, bool $includeRemovedNodes = false)
Counts nodes by its parent and (optionally) by its node type.
NOTE: Only considers persisted nodes!
protected
openIndexSpace(string $parentPath, int $referenceIndex)
Make room in the sortindex-index space of a given path in preparation to inserting a node.
All indices that are greater or equal to the given referenceIndex are incremented by 100
protected int
findNextFreeIndexInParentPath(string $parentPath)
Finds the next free index on the level below the given parent path across all workspaces.
protected void
setHighestIndexInParentPath(string $parentPath, int $highestIndex)
No description
protected int
findNextLowerIndex(string $parentPath, int $referenceIndex)
Returns the next-lower-index seen from the given reference index in the level below the specified parent path. If no node with a lower than the given index exists at that level, the reference index is returned.
The result is determined workspace-agnostic.
protected int
findNextHigherIndex(string $parentPath, int $referenceIndex)
Returns the next-higher-index seen from the given reference index in the level below the specified parent path. If no node with a higher than the given index exists at that level, NULL is returned.
The result is determined workspace-agnostic.
int
countByWorkspace(Workspace $workspace)
Counts the number of nodes within the specified workspace
Note: Also counts removed nodes
protected array
sortNodesByIndex(array $nodes)
Sorts the given nodes by their index
NodeData
findFirstByParentAndNodeType(string $parentPath, string $nodeTypeFilter, Workspace $workspace, array $dimensions, bool $removedNodes = false)
Finds a single node by its parent and (optionally) by its node type
NodeInterface
findFirstByParentAndNodeTypeInContext(string $parentPath, string $nodeTypeFilter, Context $context)
Finds a single node by its parent and (optionally) by its node type
NodeData[]
findOnPath(string $pathStartingPoint, string $pathEndPoint, Workspace $workspace, array $dimensions = null, bool $includeRemovedNodes = false, string $nodeTypeFilter = null)
Finds all nodes of the specified workspace lying on the path specified by (and including) the given starting point and end point and (optionally) a node type filter.
If some node does not exist in the specified workspace, this function will try to find a corresponding node in one of the base workspaces (if any).
NodeData[]
findByProperties(string|array $term, string $nodeTypeFilter, Workspace $workspace, array $dimensions, string $pathStartingPoint = null)
Find nodes by a value in properties
This method is internal and will be replaced with better search capabilities.
void
flushNodeRegistry()
Flushes the addedNodes and removedNodes registry.
This method is (and should only be) used as a slot to the allObjectsPersisted signal.
void
addNodeTypeFilterConstraintsToQueryBuilder(QueryBuilder $queryBuilder, string $nodeTypeFilter)
Add node type filter constraints to the query builder
protected array
getNodeTypeFilterConstraintsForDql(string|null $nodeTypeFilter = '')
Generates a two dimensional array with the filters. First level is: 'excludeNodeTypes' 'includeNodeTypes'
Both are numeric arrays with the respective node types that are included or excluded.
protected array
getNodeTypeFilterConstraints(QueryInterface $query, $nodeTypeFilter)
No description
protected void
filterOutRemovedObjects(array $objects)
Iterates of the array of objects and removes all those which have recently been removed from the repository, but whose removal has not yet been persisted.
Technically this is a check of the given array against $this->removedNodes.
protected array
withoutRemovedNodes(array $nodes)
Returns a subset of $nodes which are not flagged as removed.
protected array
onlyRemovedNodes(array $nodes)
Returns a subset of $nodes which are flagged as removed.
void
persistEntities()
Persists all entities managed by the repository and all cascading dependencies
protected void
emitRepositoryObjectsPersisted()
Signals that persistEntities() in this repository finished correctly.
protected void
addDimensionJoinConstraintsToQueryBuilder(QueryBuilder $queryBuilder, array $dimensions)
If $dimensions is not empty, adds join constraints to the given $queryBuilder limiting the query result to matching hits.
protected array
reduceNodeVariantsByWorkspacesAndDimensions(array $nodes, array $workspaces, array $dimensions)
Given an array with duplicate nodes (from different workspaces and dimensions) those are reduced to uniqueness (by node identifier)
protected array
reduceNodeVariantsByWorkspaces(array $nodes, array $workspaces)
Given an array with duplicate nodes (from different workspaces) those are reduced to uniqueness (by node identifier and dimensions hash)
NodeData[]
findByWorkspace(Workspace $workspace)
Find all NodeData objects inside a given workspace sorted by path to be used in publishing. The order makes sure that parent nodes are published first.
Shadow nodes are excluded, because they will be published when publishing the moved node.
bool
pathExists(string $nodePath)
Find out if the given path exists anywhere in the CR. (internal) If you need this functionality use \Neos\ContentRepository\Domain\Service\NodeService::nodePathExistsInAnyContext()
NodeData[]
findByPathWithoutReduce(string $path, Workspace $workspace, bool $includeRemovedNodes = false, bool $recursive = false)
Find all node data in a path matching the given workspace hierarchy
Internal method, used by Node::setPath
array
findNodesByRelatedEntities(array $relationMap)
Searches for possible relations to the given entity identifiers in NodeData.
Will return all possible NodeData objects that contain this identifiers. See buildQueryBuilderForRelationMap for the relationMap definition.
Note: This is an internal method that is likely to be replaced in the future.
array
findNodesByPathPrefixAndRelatedEntities(string $pathPrefix, array $relationMap)
Searches for possible relations to the given entity identifiers in NodeData using a path prefix.
Will return all possible NodeData objects that contain this identifiers. See buildQueryBuilderForRelationMap for the relationMap definition.
Note: This is an internal method that is likely to be replaced in the future.
void
removeAllInPath(string $path)
Remove all nodes below a given path. Does not care about workspaces and dimensions.
bool
isInRemovedNodes(NodeData $nodeData)
Test if a given NodeData is in the set of removed node data objects
protected QueryBuilder
createQueryBuilder(array $workspaces)
No description
protected void
addParentPathConstraintToQueryBuilder(QueryBuilder $queryBuilder, string $parentPath, bool $recursive = false)
No description
protected void
addPathConstraintToQueryBuilder(QueryBuilder $queryBuilder, string $path, bool $recursive = false)
No description
protected void
addIdentifierConstraintToQueryBuilder(QueryBuilder $queryBuilder, string $identifier)
No description
protected array
filterNodeDataByBestMatchInContext(array $nodeDataObjects, Workspace $workspace, array $dimensions, bool $includeRemovedNodes = false)
No description
protected array
collectWorkspaceAndAllBaseWorkspaces(Workspace $workspace)
Returns an array that contains the given workspace and all base (parent) workspaces of it.
protected QueryBuilder
buildQueryBuilderForRelationMap(array $relationMap)
Returns a query builder for a query on node data using the given relation map.
$objectTypeMap = [ 'Neos\Media\Domain\Model\Asset' => ['some-uuid-here'], 'Neos\Media\Domain\Model\ImageVariant' => ['some-uuid-here', 'another-uuid-here'] ]