1 | <?php |
||
23 | class AspectLoader |
||
24 | { |
||
25 | |||
26 | /** |
||
27 | * Aspect container instance |
||
28 | */ |
||
29 | protected $container; |
||
30 | |||
31 | /** |
||
32 | * List of aspect loaders |
||
33 | * |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $loaders = []; |
||
37 | |||
38 | /** |
||
39 | * Annotation reader for aspects |
||
40 | */ |
||
41 | protected $annotationReader; |
||
42 | |||
43 | /** |
||
44 | * List of aspects that was loaded |
||
45 | * |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $loadedAspects = []; |
||
49 | |||
50 | /** |
||
51 | * Loader constructor |
||
52 | */ |
||
53 | 9 | public function __construct(AspectContainer $container, Reader $reader) |
|
58 | |||
59 | /** |
||
60 | * Register an aspect loader extension |
||
61 | * |
||
62 | * This method allows to extend the logic of aspect loading by registering an extension for loader. |
||
63 | */ |
||
64 | 2 | public function registerLoaderExtension(AspectLoaderExtension $loader): void |
|
71 | |||
72 | /** |
||
73 | * Loads an aspect with the help of aspect loaders, but don't register it in the container |
||
74 | * |
||
75 | * @see loadAndRegister() method for registration |
||
76 | * |
||
77 | * @return Pointcut[]|Advisor[] |
||
78 | */ |
||
79 | 1 | public function load(Aspect $aspect): array |
|
104 | |||
105 | /** |
||
106 | * Loads and register all items of aspect in the container |
||
107 | */ |
||
108 | 1 | public function loadAndRegister(Aspect $aspect): void |
|
123 | |||
124 | /** |
||
125 | * Returns list of unloaded aspects in the container |
||
126 | * |
||
127 | * @return Aspect[] |
||
128 | */ |
||
129 | 1 | public function getUnloadedAspects(): array |
|
141 | |||
142 | /** |
||
143 | * Load definitions from specific aspect part into the aspect container |
||
144 | * |
||
145 | * @param Aspect $aspect Aspect instance |
||
146 | * @param Reflector $reflector Reflection instance |
||
147 | * @param array|AspectLoaderExtension[] $loaders List of loaders that can produce advisors from aspect class |
||
148 | * |
||
149 | * @throws \InvalidArgumentException If kind of loader isn't supported |
||
150 | * |
||
151 | * @return array|Pointcut[]|Advisor[] |
||
152 | */ |
||
153 | 1 | protected function loadFrom(Aspect $aspect, Reflector $reflector, array $loaders): array |
|
182 | |||
183 | /** |
||
184 | * Return list of annotations for reflection point |
||
185 | * |
||
186 | * @return array list of annotations |
||
187 | * @throws \InvalidArgumentException if $reflector is unsupported |
||
188 | */ |
||
189 | 1 | protected function getAnnotations(Reflector $reflector): array |
|
205 | } |
||
206 |