-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathCtkBuildable.php
209 lines (185 loc) · 4.9 KB
/
CtkBuildable.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
<?php
/**
* Interface for objects that can have children.
*
* PHP 5
*
* Cake Toolkit (http://caketoolkit.org)
* Copyright 2012, James Watts (http://github.com/jameswatts)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2012, James Watts (http://github.com/jameswatts)
* @link http://caketoolkit.org Cake Toolkit
* @package Ctk.Lib
* @since CakePHP(tm) v 2.2.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Interface for buildable objects.
*
* @package Ctk.Lib
*/
interface CtkBuildable {
/**
* Determines if the node has a parent node.
*
* @return boolean
*/
public function hasParent();
/**
* Returns the parent node of this node.
*
* @return CtkBuildable
*/
public function getParent();
/**
* Sets the parent node for this node.
*
* @param CtkBuildable $node The parent node.
* @return CtkBuildable
*/
public function setParent(CtkBuildable $node = null);
/**
* Determines if the node has child nodes.
*
* @return boolean
*/
public function hasChildren();
/**
* Determines if a node is a child of this node.
*
* @return boolean
*/
public function hasChild(CtkBuildable $node);
/**
* Returns the child nodes of this node.
*
* @return array
*/
public function getChildren();
/**
* Returns the first child node of this node.
*
* @return CtkBuildable
*/
public function getFirst();
/**
* Returns the last child node of this node.
*
* @return CtkBuildable
*/
public function getLast();
/**
* Returns the previous node before this node in the common parent.
*
* @return CtkBuildable
*/
public function getPrevious();
/**
* Returns the next node after this node in the common parent.
*
* @return CtkBuildable
*/
public function getNext();
/**
* Executes a callback function on each of the child nodes.
*
* @param callable $callback The callback function to use.
* @param array $data The optional array of data to be used by the callback function.
* @param boolean|int $deep Determines if applies to all children of children, or if an integer, defines the max depth.
* @return CtkBuildable
* @throws CakeException if the callback function is not callable.
*/
public function each($callback, array $data = array(), $deep = false);
/**
* Returns a duplicate of the node with a unique ID.
*
* @param array $params The optional configuration parameters to merge with exisitng values.
* @return CtkBuildable
*/
public function copy(array $params = null);
/**
* Adds a node to this node as a child.
*
* @param CtkBuildable $node Child node.
* @return CtkBuildable
*/
public function add(CtkBuildable $node);
/**
* Adds a node before the specified node.
*
* @param CtkBuildable $node Child node.
* @param CtkBuildable $before Node to add before.
* @return CtkBuildable
*/
public function addBefore(CtkBuildable $node, CtkBuildable $before);
/**
* Adds a node after the specified node.
*
* @param CtkBuildable $node Child node.
* @param CtkBuildable $after Node to add after.
* @return CtkBuildable
*/
public function addAfter(CtkBuildable $node, CtkBuildable $after);
/**
* Adds an array of nodes to this node as children.
*
* @param array $nodes The child nodes.
* @return CtkBuildable
*/
public function addMany(array $nodes);
/**
* Inherits the children of another node.
*
* @param CtkBuildable $node The node to inherit from.
* @param boolean $prepend Nodes should be added before existing children.
* @return CtkBuildable
*/
public function addFrom(CtkBuildable $node, $prepend = false);
/**
* Conditionally adds a node to this node as a child.
*
* @param boolean $condition The boolean value or expression.
* @param CtkBuildable $node Child node.
* @return CtkBuildable or null if condition is false
*/
public function addIf($condition = false, CtkBuildable $node);
/**
* Adds a node to this node as a child while the callback function returns a node.
*
* @param callable $callback The callback function to return nodes.
* @param array $data The optional array of data to be used by the callback function.
* @return CtkBuildable
*/
public function addWhile($callback, array $data = array());
/**
* Adds raw content to the children of this node.
*
* @param mixed $content The raw content to add.
* @return CtkBuildable
*/
public function addContent($content = '');
/**
* Replaces the specified node with the given node.
*
* @param CtkBuildable $node Child node.
* @param CtkBuildable $replace Node to replace.
* @return CtkBuildable
*/
public function replaceChild(CtkBuildable $node, CtkBuildable $replace);
/**
* Removes and returns a child node from this node.
*
* @param CtkBuildable $node Child node.
* @return CtkBuildable
*/
public function removeChild(CtkBuildable $node);
/**
* Removes all children from this node.
*
* @return CtkBuildable
*/
public function clearChildren();
}