1 | <?php |
||
22 | class AspectLoader |
||
23 | { |
||
24 | |||
25 | /** |
||
26 | * Aspect container instance |
||
27 | * |
||
28 | * @var null|AspectContainer |
||
29 | */ |
||
30 | protected $container = null; |
||
31 | |||
32 | /** |
||
33 | * List of aspect loaders |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $loaders = []; |
||
38 | |||
39 | /** |
||
40 | * Annotation reader for aspects |
||
41 | * |
||
42 | * @var Reader|null |
||
43 | */ |
||
44 | protected $annotationReader = null; |
||
45 | |||
46 | /** |
||
47 | * List of aspects that was loaded |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | protected $loadedAspects = []; |
||
52 | |||
53 | /** |
||
54 | * Loader constructor |
||
55 | * |
||
56 | * @param AspectContainer $container Instance of container to store pointcuts and advisors |
||
57 | * @param Reader $reader Reader for annotations that is used for aspects |
||
58 | */ |
||
59 | 13 | public function __construct(AspectContainer $container, Reader $reader) |
|
64 | |||
65 | /** |
||
66 | * Register an aspect loader extension |
||
67 | * |
||
68 | * This method allows to extend the logic of aspect loading by registering an extension for loader. |
||
69 | * |
||
70 | * @param AspectLoaderExtension $loader Loader to register |
||
71 | */ |
||
72 | 2 | public function registerLoaderExtension(AspectLoaderExtension $loader) |
|
79 | |||
80 | /** |
||
81 | * Loads an aspect with the help of aspect loaders, but don't register it in the container |
||
82 | * |
||
83 | * @see loadAndRegister() method for registration |
||
84 | * |
||
85 | * @param \Go\Aop\Aspect $aspect Aspect to load |
||
86 | * |
||
87 | * @return array|Pointcut[]|Advisor[] |
||
88 | */ |
||
89 | public function load(Aspect $aspect) |
||
114 | |||
115 | /** |
||
116 | * Loads and register all items of aspect in the container |
||
117 | * |
||
118 | * @param Aspect $aspect |
||
119 | */ |
||
120 | public function loadAndRegister(Aspect $aspect) |
||
135 | |||
136 | /** |
||
137 | * Returns list of unloaded aspects in the container |
||
138 | * |
||
139 | * @return array|Aspect[] |
||
140 | */ |
||
141 | public function getUnloadedAspects() |
||
153 | |||
154 | /** |
||
155 | * Load definitions from specific aspect part into the aspect container |
||
156 | * |
||
157 | * @param Aspect $aspect Aspect instance |
||
158 | * @param \ReflectionClass|\ReflectionMethod|\ReflectionProperty $refPoint Reflection instance |
||
159 | * @param array|AspectLoaderExtension[] $loaders List of loaders that can produce advisors from aspect class |
||
160 | * |
||
161 | * @throws \InvalidArgumentException If kind of loader isn't supported |
||
162 | * |
||
163 | * @return array|Pointcut[]|Advisor[] |
||
164 | */ |
||
165 | protected function loadFrom(Aspect $aspect, $refPoint, array $loaders) |
||
197 | |||
198 | /** |
||
199 | * Return list of annotations for reflection point |
||
200 | * |
||
201 | * @param \ReflectionClass|\ReflectionMethod|\ReflectionProperty $refPoint Reflection instance |
||
202 | * |
||
203 | * @return array list of annotations |
||
204 | * @throws \InvalidArgumentException if $refPoint is unsupported |
||
205 | */ |
||
206 | protected function getAnnotations($refPoint) |
||
222 | } |
||
223 |