1 | <?php |
||
28 | abstract class AspectKernel |
||
29 | { |
||
30 | |||
31 | /** |
||
32 | * Version of kernel |
||
33 | */ |
||
34 | const VERSION = '2.1.0'; |
||
35 | |||
36 | /** |
||
37 | * Kernel options |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $options = [ |
||
42 | 'features' => 0 |
||
43 | ]; |
||
44 | |||
45 | /** |
||
46 | * Single instance of kernel |
||
47 | * |
||
48 | * @var null|static |
||
49 | */ |
||
50 | protected static $instance; |
||
51 | |||
52 | /** |
||
53 | * Default class name for container, can be redefined in children |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | protected static $containerClass = GoAspectContainer::class; |
||
58 | |||
59 | /** |
||
60 | * Flag to determine if kernel was already initialized or not |
||
61 | * |
||
62 | * @var bool |
||
63 | */ |
||
64 | protected $wasInitialized = false; |
||
65 | |||
66 | /** |
||
67 | * Aspect container instance |
||
68 | * |
||
69 | * @var null|AspectContainer |
||
70 | */ |
||
71 | protected $container; |
||
72 | |||
73 | /** |
||
74 | * Protected constructor is used to prevent direct creation, but allows customization if needed |
||
75 | */ |
||
76 | protected function __construct() {} |
||
77 | |||
78 | /** |
||
79 | * Returns the single instance of kernel |
||
80 | * |
||
81 | * @return static |
||
82 | */ |
||
83 | public static function getInstance() |
||
91 | |||
92 | /** |
||
93 | * Init the kernel and make adjustments |
||
94 | * |
||
95 | * @param array $options Associative array of options for kernel |
||
96 | */ |
||
97 | public function init(array $options = []) |
||
131 | |||
132 | /** |
||
133 | * Returns an aspect container |
||
134 | * |
||
135 | * @return null|AspectContainer |
||
136 | */ |
||
137 | 7 | public function getContainer() |
|
141 | |||
142 | /** |
||
143 | * Checks if kernel configuration has enabled specific feature |
||
144 | * |
||
145 | * @param integer $featureToCheck See Go\Aop\Features enumeration class for features |
||
146 | * |
||
147 | * @return bool Whether specific feature enabled or not |
||
148 | */ |
||
149 | public function hasFeature($featureToCheck) |
||
153 | |||
154 | /** |
||
155 | * Returns list of kernel options |
||
156 | * |
||
157 | * @return array |
||
158 | */ |
||
159 | public function getOptions() |
||
163 | |||
164 | /** |
||
165 | * Returns default options for kernel. Available options: |
||
166 | * |
||
167 | * debug - boolean Determines whether or not kernel is in debug mode |
||
168 | * appDir - string Path to the application root directory. |
||
169 | * cacheDir - string Path to the cache directory where compiled classes will be stored |
||
170 | * cacheFileMode - integer Binary mask of permission bits that is set to cache files |
||
171 | * annotationCache - Doctrine\Common\Cache\Cache. If not provided, Doctrine\Common\Cache\PhpFileCache is used. |
||
172 | * features - integer Binary mask of features |
||
173 | * includePaths - array Whitelist of directories where aspects should be applied. Empty for everywhere. |
||
174 | * excludePaths - array Blacklist of directories or files where aspects shouldn't be applied. |
||
175 | * |
||
176 | * @return array |
||
177 | */ |
||
178 | protected function getDefaultOptions() |
||
192 | |||
193 | |||
194 | /** |
||
195 | * Normalizes options for the kernel |
||
196 | * |
||
197 | * @param array $options List of options |
||
198 | * |
||
199 | * @return array |
||
200 | */ |
||
201 | protected function normalizeOptions(array $options) |
||
220 | |||
221 | /** |
||
222 | * Configure an AspectContainer with advisors, aspects and pointcuts |
||
223 | * |
||
224 | * @param AspectContainer $container |
||
225 | * |
||
226 | * @return void |
||
227 | */ |
||
228 | abstract protected function configureAop(AspectContainer $container); |
||
229 | |||
230 | /** |
||
231 | * Returns list of source transformers, that will be applied to the PHP source |
||
232 | * |
||
233 | * @return array|SourceTransformer[] |
||
234 | */ |
||
235 | protected function registerTransformers() |
||
267 | |||
268 | /** |
||
269 | * Add resources for kernel |
||
270 | * |
||
271 | * @param AspectContainer $container |
||
272 | */ |
||
273 | protected function addKernelResourcesToContainer(AspectContainer $container) |
||
281 | } |
||
282 |