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 | * @var bool |
||
58 | */ |
||
59 | private $indexingEnabled = true; |
||
60 | |||
61 | /** |
||
62 | * @param array $callbacks |
||
63 | * @param ContainerInterface $container |
||
64 | */ |
||
65 | 25 | public function __construct(array $callbacks, ContainerInterface $container) |
|
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 | 18 | public function isObjectIndexable($indexName, $typeName, $object) |
|
104 | |||
105 | /** |
||
106 | * Returns true if global indexing is enabled, false otherwise. |
||
107 | * |
||
108 | * @return bool |
||
109 | */ |
||
110 | public function isIndexingEnabled() |
||
114 | |||
115 | /** |
||
116 | * Sets global indexing. |
||
117 | * |
||
118 | * @param bool $indexingEnabled |
||
119 | */ |
||
120 | 1 | public function setIndexingEnabled($indexingEnabled) |
|
124 | |||
125 | /** |
||
126 | * Builds and initialises a callback. |
||
127 | * |
||
128 | * @param string $type |
||
129 | * @param object $object |
||
130 | * |
||
131 | * @return mixed |
||
132 | */ |
||
133 | 17 | private function buildCallback($type, $object) |
|
155 | |||
156 | /** |
||
157 | * Processes a string expression into an Expression. |
||
158 | * |
||
159 | * @param string $type |
||
160 | * @param mixed $object |
||
161 | * @param string $callback |
||
162 | * |
||
163 | * @return Expression |
||
164 | */ |
||
165 | 8 | private function buildExpressionCallback($type, $object, $callback) |
|
186 | |||
187 | /** |
||
188 | * Retreives a cached callback, or creates a new callback if one is not found. |
||
189 | * |
||
190 | * @param string $type |
||
191 | * @param object $object |
||
192 | * |
||
193 | * @return mixed |
||
194 | */ |
||
195 | 17 | private function getCallback($type, $object) |
|
203 | |||
204 | /** |
||
205 | * Returns the ExpressionLanguage class if it is available. |
||
206 | * |
||
207 | * @return ExpressionLanguage|null |
||
208 | */ |
||
209 | 8 | private function getExpressionLanguage() |
|
217 | |||
218 | /** |
||
219 | * Returns the variable name to be used to access the object when using the ExpressionLanguage |
||
220 | * component to parse and evaluate an expression. |
||
221 | * |
||
222 | * @param mixed $object |
||
223 | * |
||
224 | * @return string |
||
225 | */ |
||
226 | 8 | private function getExpressionVar($object = null) |
|
236 | |||
237 | /** |
||
238 | * Processes an array into a callback. Replaces the first element with a service if |
||
239 | * it begins with an @. |
||
240 | * |
||
241 | * @param string $type |
||
242 | * @param array $callback |
||
243 | * |
||
244 | * @return array |
||
245 | */ |
||
246 | 4 | private function processArrayToCallback($type, array $callback) |
|
270 | } |
||
271 |