/
TraversableNodeInterface.php
136 lines (122 loc) · 5.04 KB
/
TraversableNodeInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
declare(strict_types=1);
namespace Neos\ContentRepository\Domain\Projection\Content;
/*
* This file is part of the Neos.ContentRepository package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use Neos\ContentRepository\DimensionSpace\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Domain\NodeAggregate\NodeName;
use Neos\ContentRepository\Domain\ContentSubgraph\NodePath;
use Neos\ContentRepository\Domain\NodeType\NodeTypeConstraints;
use Neos\ContentRepository\Exception\NodeException;
use Neos\EventSourcedContentRepository\Domain\ValueObject\PropertyName;
/**
* This is a NEW interface, introduced in Neos 4.3; and it will become the main interface
* with Neos 5.0 to the CR.
*
* The main convenience Event-Sourced NodeInterface used for READING; containing
* data accessors and traversal methods.
*
* All methods which are called `get*()` contain only information local to a node,
* so they can be accessed really quickly without any external lookup.
*
* All methods which are called `find*()` may involve some database querying to
* fetch their information.
*
* The TraversableNodeInterface is *immutable*, meaning its contents never change after creation.
* It is *only used for reading*.
*
* Starting with version 5.0 (when backed by the Event Sourced CR), it is
* *completely detached from storage*; so it will not auto-update after a property changed in
* storage.
*/
interface TraversableNodeInterface extends NodeInterface
{
/**
* Returns the DimensionSpacePoint the node was *requested in*, i.e. one of the DimensionSpacePoints
* this node is visible in. If you need the DimensionSpacePoint where the node is actually at home,
* see getOriginDimensionSpacePoint()
*
* @return DimensionSpacePoint
*/
public function getDimensionSpacePoint(): DimensionSpacePoint;
/**
* Retrieves and returns the parent node from the node's subgraph.
* If no parent node is present, an {@link NodeException} is thrown.
*
* @return TraversableNodeInterface the parent node, never <code>null</code>
* @throws NodeException If this node has no parent (i.e. is the root)
*/
public function findParentNode(): TraversableNodeInterface;
/**
* Retrieves and returns the node's path to its root node.
*
* @return NodePath
*/
public function findNodePath(): NodePath;
/**
* Retrieves and returns a child node by name from the node's subgraph.
*
* @param NodeName $nodeName The name
* @return TraversableNodeInterface
* @throws NodeException If no child node with the given $nodeName can be found
*/
public function findNamedChildNode(NodeName $nodeName): TraversableNodeInterface;
/**
* Retrieves and returns all direct child nodes of this node from its subgraph.
* If node type constraints are specified, only nodes of that type are returned.
*
* @param NodeTypeConstraints $nodeTypeConstraints If specified, only nodes with that node type are considered
* @param int $limit An optional limit for the number of nodes to find. Added or removed nodes can still change the number nodes!
* @param int $offset An optional offset for the query
* @return TraversableNodes Traversable nodes that matched the given constraints
* @api
*/
public function findChildNodes(NodeTypeConstraints $nodeTypeConstraints = null, int $limit = null, int $offset = null): TraversableNodes;
/**
* Returns the number of direct child nodes of this node from its subgraph.
*
* @param NodeTypeConstraints|null $nodeTypeConstraints If specified, only nodes with that node type are considered
* @return int
*/
public function countChildNodes(NodeTypeConstraints $nodeTypeConstraints = null): int;
/**
* Retrieves and returns all nodes referenced by this node from its subgraph.
*
* @return TraversableNodes
*/
public function findReferencedNodes(): TraversableNodes;
/**
* Retrieves and returns nodes referenced by this node by name from its subgraph.
*
* @param PropertyName $edgeName
* @return TraversableNodes
*/
public function findNamedReferencedNodes(PropertyName $edgeName): TraversableNodes;
/**
* Retrieves and returns nodes referencing this node from its subgraph.
*
* @return TraversableNodes
*/
public function findReferencingNodes(): TraversableNodes;
/**
* Retrieves and returns nodes referencing this node by name from its subgraph.
*
* @param PropertyName $nodeName
* @return TraversableNodes
*/
public function findNamedReferencingNodes(PropertyName $nodeName): TraversableNodes;
/**
* Compare whether two traversable nodes are equal
*
* @param TraversableNodeInterface $other
* @return bool
*/
public function equals(TraversableNodeInterface $other): bool;
}