1 | <?php |
||
31 | class Indexable implements IndexableInterface, ContainerAwareInterface |
||
32 | { |
||
33 | use ContainerAwareTrait; |
||
34 | |||
35 | /** |
||
36 | * An array of raw configured callbacks for all types. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | private $callbacks = []; |
||
41 | |||
42 | /** |
||
43 | * An instance of ExpressionLanguage. |
||
44 | * |
||
45 | * @var ExpressionLanguage |
||
46 | */ |
||
47 | private $expressionLanguage; |
||
48 | |||
49 | /** |
||
50 | * An array of initialised callbacks. |
||
51 | * |
||
52 | * @var array |
||
53 | */ |
||
54 | private $initialisedCallbacks = []; |
||
55 | |||
56 | /** |
||
57 | * PropertyAccessor instance. |
||
58 | * |
||
59 | * @var PropertyAccessorInterface |
||
60 | */ |
||
61 | private $propertyAccessor; |
||
62 | |||
63 | /** |
||
64 | * @param array $callbacks |
||
65 | */ |
||
66 | 25 | public function __construct(array $callbacks) |
|
71 | |||
72 | /** |
||
73 | * Return whether the object is indexable with respect to the callback. |
||
74 | * |
||
75 | * @param string $indexName |
||
76 | * @param string $typeName |
||
77 | * @param mixed $object |
||
78 | * |
||
79 | * @return bool |
||
80 | */ |
||
81 | 17 | public function isObjectIndexable($indexName, $typeName, $object) |
|
100 | |||
101 | /** |
||
102 | * Builds and initialises a callback. |
||
103 | * |
||
104 | * @param string $type |
||
105 | * @param object $object |
||
106 | * |
||
107 | * @return mixed |
||
108 | */ |
||
109 | 17 | private function buildCallback($type, $object) |
|
131 | |||
132 | /** |
||
133 | * Processes a string expression into an Expression. |
||
134 | * |
||
135 | * @param string $type |
||
136 | * @param mixed $object |
||
137 | * @param string $callback |
||
138 | * |
||
139 | * @return Expression |
||
140 | */ |
||
141 | 8 | private function buildExpressionCallback($type, $object, $callback) |
|
162 | |||
163 | /** |
||
164 | * Retreives a cached callback, or creates a new callback if one is not found. |
||
165 | * |
||
166 | * @param string $type |
||
167 | * @param object $object |
||
168 | * |
||
169 | * @return mixed |
||
170 | */ |
||
171 | 17 | private function getCallback($type, $object) |
|
179 | |||
180 | /** |
||
181 | * Returns the ExpressionLanguage class if it is available. |
||
182 | * |
||
183 | * @return ExpressionLanguage|null |
||
184 | */ |
||
185 | 8 | private function getExpressionLanguage() |
|
193 | |||
194 | /** |
||
195 | * Returns the variable name to be used to access the object when using the ExpressionLanguage |
||
196 | * component to parse and evaluate an expression. |
||
197 | * |
||
198 | * @param mixed $object |
||
199 | * |
||
200 | * @return string |
||
201 | */ |
||
202 | 8 | private function getExpressionVar($object = null) |
|
212 | |||
213 | /** |
||
214 | * Processes an array into a callback. Replaces the first element with a service if |
||
215 | * it begins with an @. |
||
216 | * |
||
217 | * @param string $type |
||
218 | * @param array $callback |
||
219 | * |
||
220 | * @return array |
||
221 | */ |
||
222 | 4 | private function processArrayToCallback($type, array $callback) |
|
246 | } |
||
247 |