1 | <?php |
||
27 | abstract class AspectKernel |
||
28 | { |
||
29 | |||
30 | /** |
||
31 | * Version of kernel |
||
32 | */ |
||
33 | const VERSION = '1.0.0'; |
||
34 | |||
35 | /** |
||
36 | * Kernel options |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $options = array( |
||
41 | 'features' => 0 |
||
42 | ); |
||
43 | |||
44 | /** |
||
45 | * Single instance of kernel |
||
46 | * |
||
47 | * @var null|static |
||
48 | */ |
||
49 | protected static $instance = null; |
||
50 | |||
51 | /** |
||
52 | * Default class name for container, can be redefined in children |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected static $containerClass = GoAspectContainer::class; |
||
57 | |||
58 | /** |
||
59 | * Aspect container instance |
||
60 | * |
||
61 | * @var null|AspectContainer |
||
62 | */ |
||
63 | protected $container = null; |
||
64 | |||
65 | /** |
||
66 | * Protected constructor is used to prevent direct creation, but allows customization if needed |
||
67 | */ |
||
68 | protected function __construct() {} |
||
69 | |||
70 | /** |
||
71 | * Returns the single instance of kernel |
||
72 | * |
||
73 | * @return AspectKernel |
||
74 | */ |
||
75 | public static function getInstance() |
||
83 | |||
84 | /** |
||
85 | * Init the kernel and make adjustments |
||
86 | * |
||
87 | * @param array $options Associative array of options for kernel |
||
88 | */ |
||
89 | public function init(array $options = []) |
||
117 | |||
118 | /** |
||
119 | * Returns an aspect container |
||
120 | * |
||
121 | * @return null|AspectContainer |
||
122 | */ |
||
123 | 6 | public function getContainer() |
|
127 | |||
128 | /** |
||
129 | * Checks if kernel configuration has enabled specific feature |
||
130 | * |
||
131 | * @param integer $featureToCheck See Go\Aop\Features enumeration class for features |
||
132 | * |
||
133 | * @return bool Whether specific feature enabled or not |
||
134 | */ |
||
135 | public function hasFeature($featureToCheck) |
||
139 | |||
140 | /** |
||
141 | * Returns list of kernel options |
||
142 | * |
||
143 | * @return array |
||
144 | */ |
||
145 | public function getOptions() |
||
149 | |||
150 | /** |
||
151 | * Returns default options for kernel. Available options: |
||
152 | * |
||
153 | * debug - boolean Determines whether or not kernel is in debug mode |
||
154 | * appDir - string Path to the application root directory. |
||
155 | * cacheDir - string Path to the cache directory where compiled classes will be stored |
||
156 | * cacheFileMode - integer Binary mask of permission bits that is set to cache files |
||
157 | * features - integer Binary mask of features |
||
158 | * includePaths - array Whitelist of directories where aspects should be applied. Empty for everywhere. |
||
159 | * excludePaths - array Blacklist of directories or files where aspects shouldn't be applied. |
||
160 | * |
||
161 | * @return array |
||
162 | */ |
||
163 | protected function getDefaultOptions() |
||
177 | |||
178 | |||
179 | /** |
||
180 | * Normalizes options for the kernel |
||
181 | * |
||
182 | * @param array $options List of options |
||
183 | * |
||
184 | * @return array |
||
185 | */ |
||
186 | protected function normalizeOptions(array $options) |
||
201 | |||
202 | /** |
||
203 | * Configure an AspectContainer with advisors, aspects and pointcuts |
||
204 | * |
||
205 | * @param AspectContainer $container |
||
206 | * |
||
207 | * @return void |
||
208 | */ |
||
209 | abstract protected function configureAop(AspectContainer $container); |
||
210 | |||
211 | /** |
||
212 | * Returns list of source transformers, that will be applied to the PHP source |
||
213 | * |
||
214 | * @return array|SourceTransformer[] |
||
215 | */ |
||
216 | protected function registerTransformers() |
||
248 | |||
249 | /** |
||
250 | * Add resources for kernel |
||
251 | * |
||
252 | * @param AspectContainer $container |
||
253 | */ |
||
254 | protected function addKernelResourcesToContainer(AspectContainer $container) |
||
262 | } |
||
263 |