1 | <?php |
||
22 | class Indexable implements IndexableInterface, ContainerAwareInterface |
||
23 | { |
||
24 | use ContainerAwareTrait; |
||
25 | |||
26 | /** |
||
27 | * An array of raw configured callbacks for all types. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | private $callbacks = array(); |
||
32 | |||
33 | /** |
||
34 | * An instance of ExpressionLanguage. |
||
35 | * |
||
36 | * @var ExpressionLanguage |
||
37 | */ |
||
38 | private $expressionLanguage; |
||
39 | |||
40 | /** |
||
41 | * An array of initialised callbacks. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | private $initialisedCallbacks = array(); |
||
46 | |||
47 | /** |
||
48 | * PropertyAccessor instance. |
||
49 | * |
||
50 | * @var PropertyAccessorInterface |
||
51 | */ |
||
52 | private $propertyAccessor; |
||
53 | |||
54 | /** |
||
55 | * @param array $callbacks |
||
56 | */ |
||
57 | 24 | public function __construct(array $callbacks) |
|
62 | |||
63 | /** |
||
64 | * Return whether the object is indexable with respect to the callback. |
||
65 | * |
||
66 | * @param string $indexName |
||
67 | * @param string $typeName |
||
68 | * @param mixed $object |
||
69 | * |
||
70 | * @return bool |
||
71 | */ |
||
72 | 17 | public function isObjectIndexable($indexName, $typeName, $object) |
|
91 | |||
92 | /** |
||
93 | * Builds and initialises a callback. |
||
94 | * |
||
95 | * @param string $type |
||
96 | * @param object $object |
||
97 | * |
||
98 | * @return mixed |
||
99 | */ |
||
100 | 17 | private function buildCallback($type, $object) |
|
122 | |||
123 | /** |
||
124 | * Processes a string expression into an Expression. |
||
125 | * |
||
126 | * @param string $type |
||
127 | * @param mixed $object |
||
128 | * @param string $callback |
||
129 | * |
||
130 | * @return Expression |
||
131 | */ |
||
132 | 8 | private function buildExpressionCallback($type, $object, $callback) |
|
153 | |||
154 | /** |
||
155 | * Retreives a cached callback, or creates a new callback if one is not found. |
||
156 | * |
||
157 | * @param string $type |
||
158 | * @param object $object |
||
159 | * |
||
160 | * @return mixed |
||
161 | */ |
||
162 | 17 | private function getCallback($type, $object) |
|
170 | |||
171 | /** |
||
172 | * Returns the ExpressionLanguage class if it is available. |
||
173 | * |
||
174 | * @return ExpressionLanguage|null |
||
175 | */ |
||
176 | 8 | private function getExpressionLanguage() |
|
184 | |||
185 | /** |
||
186 | * Returns the variable name to be used to access the object when using the ExpressionLanguage |
||
187 | * component to parse and evaluate an expression. |
||
188 | * |
||
189 | * @param mixed $object |
||
190 | * |
||
191 | * @return string |
||
192 | */ |
||
193 | 8 | private function getExpressionVar($object = null) |
|
203 | |||
204 | /** |
||
205 | * Processes an array into a callback. Replaces the first element with a service if |
||
206 | * it begins with an @. |
||
207 | * |
||
208 | * @param string $type |
||
209 | * @param array $callback |
||
210 | * |
||
211 | * @return array |
||
212 | */ |
||
213 | 4 | private function processArrayToCallback($type, array $callback) |
|
237 | } |
||
238 |