| 1 | <?php |
||
| 12 | class Queries |
||
|
|
|||
| 13 | { |
||
| 14 | |||
| 15 | private $customizers = []; |
||
| 16 | |||
| 17 | 1 | public function addCustomizer(QueryCustomizer $customizer) { |
|
| 18 | 1 | if (!$customizer) { |
|
| 19 | throw new InvalidArgumentException('Customizer should not be null.'); |
||
| 20 | } |
||
| 21 | 1 | $reader = new AnnotationReader(); |
|
| 22 | 1 | $rc = new \ReflectionClass($customizer); |
|
| 23 | 1 | $anno = $reader->getClassAnnotation($rc, QueryExtension::class); |
|
| 24 | 1 | if (!$anno) { |
|
| 25 | throw new InvalidArgumentException(get_class($customizer).' doesn\'t have any '.QueryExtension::class.' annotation.'); |
||
| 26 | } |
||
| 27 | 1 | foreach ($anno->value as $queryKey) { |
|
| 28 | 1 | $this->customizers[$queryKey][] = $customizer; |
|
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | 1 | public function customize($queryKey, QueryBuilder $builder, $params) |
|
| 42 | } |