1 | <?php |
||
21 | class Indexable implements IndexableInterface |
||
22 | { |
||
23 | /** |
||
24 | * An array of raw configured callbacks for all types. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | private $callbacks = array(); |
||
29 | |||
30 | /** |
||
31 | * @var \Symfony\Component\DependencyInjection\ContainerInterface |
||
32 | */ |
||
33 | private $container; |
||
34 | |||
35 | /** |
||
36 | * An instance of ExpressionLanguage. |
||
37 | * |
||
38 | * @var ExpressionLanguage |
||
39 | */ |
||
40 | private $expressionLanguage; |
||
41 | |||
42 | /** |
||
43 | * An array of initialised callbacks. |
||
44 | * |
||
45 | * @var array |
||
46 | */ |
||
47 | private $initialisedCallbacks = array(); |
||
48 | |||
49 | /** |
||
50 | * PropertyAccessor instance. |
||
51 | * |
||
52 | * @var PropertyAccessorInterface |
||
53 | */ |
||
54 | private $propertyAccessor; |
||
55 | |||
56 | /** |
||
57 | * @param array $callbacks |
||
58 | * @param ContainerInterface $container |
||
59 | */ |
||
60 | 16 | public function __construct(array $callbacks, ContainerInterface $container) |
|
66 | |||
67 | /** |
||
68 | * Return whether the object is indexable with respect to the callback. |
||
69 | * |
||
70 | * @param string $indexName |
||
71 | * @param string $typeName |
||
72 | * @param mixed $object |
||
73 | * |
||
74 | * @return bool |
||
75 | */ |
||
76 | 16 | public function isObjectIndexable($indexName, $typeName, $object) |
|
95 | |||
96 | /** |
||
97 | * Builds and initialises a callback. |
||
98 | * |
||
99 | * @param string $type |
||
100 | * @param object $object |
||
101 | * |
||
102 | * @return mixed |
||
103 | */ |
||
104 | 16 | private function buildCallback($type, $object) |
|
126 | |||
127 | /** |
||
128 | * Processes a string expression into an Expression. |
||
129 | * |
||
130 | * @param string $type |
||
131 | * @param mixed $object |
||
132 | * @param string $callback |
||
133 | * |
||
134 | * @return Expression |
||
135 | */ |
||
136 | 7 | private function buildExpressionCallback($type, $object, $callback) |
|
157 | |||
158 | /** |
||
159 | * Retreives a cached callback, or creates a new callback if one is not found. |
||
160 | * |
||
161 | * @param string $type |
||
162 | * @param object $object |
||
163 | * |
||
164 | * @return mixed |
||
165 | */ |
||
166 | 16 | private function getCallback($type, $object) |
|
174 | |||
175 | /** |
||
176 | * Returns the ExpressionLanguage class if it is available. |
||
177 | * |
||
178 | * @return ExpressionLanguage|null |
||
179 | */ |
||
180 | 7 | private function getExpressionLanguage() |
|
188 | |||
189 | /** |
||
190 | * Returns the variable name to be used to access the object when using the ExpressionLanguage |
||
191 | * component to parse and evaluate an expression. |
||
192 | * |
||
193 | * @param mixed $object |
||
194 | * |
||
195 | * @return string |
||
196 | */ |
||
197 | 7 | private function getExpressionVar($object = null) |
|
207 | |||
208 | /** |
||
209 | * Processes an array into a callback. Replaces the first element with a service if |
||
210 | * it begins with an @. |
||
211 | * |
||
212 | * @param string $type |
||
213 | * @param array $callback |
||
214 | * @return array |
||
215 | */ |
||
216 | 3 | private function processArrayToCallback($type, array $callback) |
|
240 | } |
||
241 |