1 | <?php |
||
23 | class ModelObjNode extends BaseNode |
||
24 | { |
||
25 | /** |
||
26 | * @var int|string |
||
27 | */ |
||
28 | protected $id; |
||
29 | |||
30 | /** |
||
31 | * @var EEM_Base |
||
32 | */ |
||
33 | protected $model; |
||
34 | |||
35 | /** |
||
36 | * @var RelationNode[] |
||
37 | */ |
||
38 | protected $nodes; |
||
39 | |||
40 | /** |
||
41 | * We don't pass the model objects because this needs to serialize to something tiny for effiency. |
||
42 | * @param $model_obj_id |
||
43 | * @param EEM_Base $model |
||
44 | * @param array $dont_traverse_models array of model names we DON'T want to traverse. |
||
45 | */ |
||
46 | public function __construct($model_obj_id, EEM_Base $model, array $dont_traverse_models = []) |
||
52 | |||
53 | /** |
||
54 | * Creates a relation node for each relation of this model's relations. |
||
55 | * Does NOT call `discover` on them yet though. |
||
56 | * @since $VID:$ |
||
57 | * @throws \EE_Error |
||
58 | * @throws InvalidDataTypeException |
||
59 | * @throws InvalidInterfaceException |
||
60 | * @throws InvalidArgumentException |
||
61 | * @throws ReflectionException |
||
62 | */ |
||
63 | protected function discover() |
||
93 | |||
94 | |||
95 | /** |
||
96 | * Whether this item has already been initialized |
||
97 | */ |
||
98 | protected function isDiscovered() |
||
102 | |||
103 | /** |
||
104 | * @since $VID:$ |
||
105 | * @return boolean |
||
106 | */ |
||
107 | public function isComplete() |
||
114 | |||
115 | /** |
||
116 | * Triggers working on each child relation node that has work to do. |
||
117 | * @since $VID:$ |
||
118 | * @param $model_objects_to_identify |
||
119 | * @return int units of work done |
||
120 | */ |
||
121 | protected function work($model_objects_to_identify) |
||
141 | |||
142 | /** |
||
143 | * @since $VID:$ |
||
144 | * @return array |
||
145 | * @throws \EE_Error |
||
146 | * @throws InvalidDataTypeException |
||
147 | * @throws InvalidInterfaceException |
||
148 | * @throws InvalidArgumentException |
||
149 | * @throws ReflectionException |
||
150 | */ |
||
151 | public function toArray() |
||
167 | |||
168 | /** |
||
169 | * @since $VID:$ |
||
170 | * @return array|mixed |
||
171 | * @throws InvalidArgumentException |
||
172 | * @throws InvalidDataTypeException |
||
173 | * @throws InvalidInterfaceException |
||
174 | * @throws ReflectionException |
||
175 | * @throws \EE_Error |
||
176 | */ |
||
177 | public function getIds() |
||
191 | |||
192 | /** |
||
193 | * Don't serialize the models. Just record their names on some dynamic properties. |
||
194 | * @since $VID:$ |
||
195 | */ |
||
196 | public function __sleep() |
||
208 | |||
209 | /** |
||
210 | * Use the dynamic properties to instantiate the models we use. |
||
211 | * @since $VID:$ |
||
212 | * @throws EE_Error |
||
213 | * @throws InvalidArgumentException |
||
214 | * @throws InvalidDataTypeException |
||
215 | * @throws InvalidInterfaceException |
||
216 | * @throws ReflectionException |
||
217 | */ |
||
218 | public function __wakeup() |
||
223 | } |
||
224 | // End of file Visitor.php |
||
226 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: