-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathNestedSetInterface.php
211 lines (189 loc) · 4.97 KB
/
NestedSetInterface.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?php
namespace PNX\NestedSet;
/**
* Provides a tree implementation.
*/
interface NestedSetInterface {
/**
* Inserts a node below the target node.
*
* @param \PNX\NestedSet\NodeKey $parent
* The target node to insert below.
* @param \PNX\NestedSet\NodeKey $child
* The node to insert.
*
* @return \PNX\NestedSet\Node
* Returns a new node with position values set.
*/
public function addNodeBelow(NodeKey $parent, NodeKey $child);
/**
* Inserts a node before the target node.
*
* @param \PNX\NestedSet\NodeKey $targetKey
* The target node to insert before.
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node key to insert.
*
* @return \PNX\NestedSet\Node
* Returns a node with position values set.
*/
public function addNodeBefore(NodeKey $targetKey, NodeKey $nodeKey);
/**
* Inserts a node after the target node.
*
* @param \PNX\NestedSet\NodeKey $targetKey
* The target node to insert after.
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node key to insert.
*
* @return \PNX\NestedSet\Node
* Returns a node with position values set.
*/
public function addNodeAfter(NodeKey $targetKey, NodeKey $nodeKey);
/**
* Inserts a root node.
*
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node key to insert.
*
* @return \PNX\NestedSet\Node
* A new node with position values set.
*/
public function addRootNode(NodeKey $nodeKey);
/**
* Deletes a node and moves descendants up a level.
*
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node to delete.
*/
public function deleteNode(NodeKey $nodeKey);
/**
* Deletes a node and all it's descendants.
*
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node to delete.
*/
public function deleteSubTree(NodeKey $nodeKey);
/**
* Finds all descendants of a node.
*
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node key to find descendants for.
* @param int $depth
* (optional) A depth limit. Defaults to 0, no limit.
*
* @return array
* The nested array of descendants.
*/
public function findDescendants(NodeKey $nodeKey, $depth = 0);
/**
* Finds all immediate children of a node.
*
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node key to find children for.
*
* @return array
* The children.
*/
public function findChildren(NodeKey $nodeKey);
/**
* Finds all ancestors of a node.
*
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node to find ancestors for.
*
* @return array
* The ancestors.
*/
public function findAncestors(NodeKey $nodeKey);
/**
* Finds the parent node.
*
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node key.
*
* @return \PNX\NestedSet\Node
* The parent node.
*/
public function findParent(NodeKey $nodeKey);
/**
* Gets a node for the ID and Revision ID.
*
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node key.
*
* @return \PNX\NestedSet\Node
* The node.
*/
public function getNode(NodeKey $nodeKey);
/**
* Moves a subtree to be a new root of the tree.
*
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node to become the new root node.
*/
public function moveSubTreeToRoot(NodeKey $nodeKey);
/**
* Moves a node and its sub-tree below the target node.
*
* @param \PNX\NestedSet\NodeKey $targetKey
* The node to move below.
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node to move.
*/
public function moveSubTreeBelow(NodeKey $targetKey, NodeKey $nodeKey);
/**
* Moves a node and its sub-tree before the target node.
*
* @param \PNX\NestedSet\NodeKey $targetKey
* The node to move before.
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node to move.
*/
public function moveSubTreeBefore(NodeKey $targetKey, NodeKey $nodeKey);
/**
* Moves a node and its sub-tree after the target node.
*
* @param \PNX\NestedSet\NodeKey $targetKey
* The node to move after.
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node to move.
*/
public function moveSubTreeAfter(NodeKey $targetKey, NodeKey $nodeKey);
/**
* Swaps the parent of a sub-tree to a new parent.
*
* @param \PNX\NestedSet\NodeKey $oldParentKey
* The old parent.
* @param \PNX\NestedSet\NodeKey $newParentKey
* The new parent.
*/
public function adoptChildren(NodeKey $oldParentKey, NodeKey $newParentKey);
/**
* Gets a node at a specified left position.
*
* @param int $left
* The left position.
*
* @return Node
* The node.
*/
public function getNodeAtPosition($left);
/**
* Fetches the entire tree.
*
* @return array
* The tree.
*/
public function getTree();
/**
* Finds the root node for this node.
*
* @param \PNX\NestedSet\NodeKey $nodeKey
* The node key.
*
* @return \PNX\NestedSet\Node
* The root node.
*/
public function findRoot(NodeKey $nodeKey);
}