1 | <?php |
||
30 | class Plugin extends CakePlugin |
||
31 | { |
||
32 | |||
33 | /** |
||
34 | * Plugin bootstrap file. |
||
35 | */ |
||
36 | const FILE_BOOTSTRAP = 'bootstrap.php'; |
||
37 | |||
38 | /** |
||
39 | * Plugin routes file. |
||
40 | */ |
||
41 | const FILE_ROUTES = 'routes.php'; |
||
42 | |||
43 | /** |
||
44 | * The plugin manifest file name. |
||
45 | */ |
||
46 | const PLUGIN_MANIFEST = 'plugin.manifest.php'; |
||
47 | |||
48 | /** |
||
49 | * Hold plugin data. |
||
50 | * |
||
51 | * @var array |
||
52 | */ |
||
53 | protected static $_data = []; |
||
54 | |||
55 | /** |
||
56 | * Holds a list of all plugin events from manifest file. |
||
57 | * |
||
58 | * @var array |
||
59 | */ |
||
60 | protected static $_eventList = []; |
||
61 | |||
62 | /** |
||
63 | * Manifest callback list. |
||
64 | * |
||
65 | * @var array |
||
66 | */ |
||
67 | protected static $_manifestEvents = [ |
||
68 | 'Controller.initialize', |
||
69 | 'Controller.beforeRender', |
||
70 | 'Controller.beforeFilter', |
||
71 | 'Controller.beforeRedirect', |
||
72 | 'Controller.afterFilter', |
||
73 | 'View.initialize', |
||
74 | 'View.beforeRenderFile', |
||
75 | 'View.afterRenderFile', |
||
76 | 'View.beforeRender', |
||
77 | 'View.afterRender', |
||
78 | 'View.beforeLayout', |
||
79 | ]; |
||
80 | |||
81 | /** |
||
82 | * Get plugin manifest data. |
||
83 | * |
||
84 | * @param string $plugin |
||
85 | * @param null|string $key |
||
86 | * @return Data |
||
87 | */ |
||
88 | public static function getData($plugin, $key = null) |
||
105 | |||
106 | /** |
||
107 | * Get plugin locale path. |
||
108 | * |
||
109 | * @param string $plugin |
||
110 | * @return string |
||
111 | */ |
||
112 | public static function getLocalePath($plugin) |
||
116 | |||
117 | /** |
||
118 | * Get absolute plugin manifest file path. |
||
119 | * |
||
120 | * @param string $plugin |
||
121 | * @return null|string |
||
122 | */ |
||
123 | public static function getManifestPath($plugin) |
||
131 | |||
132 | /** |
||
133 | * Check manifest event. |
||
134 | * |
||
135 | * @param string $name Plugin name. |
||
136 | * @return bool |
||
137 | */ |
||
138 | public static function hasManifestEvent($name) |
||
142 | |||
143 | /** |
||
144 | * Call plugin manifest callbacks. |
||
145 | * |
||
146 | * @return void |
||
147 | */ |
||
148 | public static function manifestEvent() |
||
160 | |||
161 | /** |
||
162 | * Unload the plugin. |
||
163 | * |
||
164 | * @param null|string $plugin |
||
165 | * @return void |
||
166 | */ |
||
167 | public static function unload($plugin = null) |
||
183 | |||
184 | /** |
||
185 | * Registration plugin manifest callbacks. |
||
186 | * |
||
187 | * @param string $plugin |
||
188 | * @return void |
||
189 | */ |
||
190 | public static function addManifestCallback($plugin) |
||
199 | |||
200 | /** |
||
201 | * Check plugin data. |
||
202 | * |
||
203 | * @param string $plugin |
||
204 | * @return array |
||
205 | */ |
||
206 | protected static function _checkData($plugin) |
||
210 | |||
211 | /** |
||
212 | * Find plugin dir in registered paths. |
||
213 | * |
||
214 | * @param string $name |
||
215 | * @return null|string |
||
216 | */ |
||
217 | public static function findPlugin($name) |
||
237 | |||
238 | /** |
||
239 | * Get plugin configuration for load plugin. |
||
240 | * |
||
241 | * @param string $path |
||
242 | * @return array |
||
243 | */ |
||
244 | public static function getConfigForLoad($path) |
||
262 | |||
263 | /** |
||
264 | * Get current plugin data. |
||
265 | * |
||
266 | * @param array $data |
||
267 | * @param null|string $key |
||
268 | * @return Data |
||
269 | */ |
||
270 | protected static function _getPluginData(array $data, $key = null) |
||
278 | |||
279 | /** |
||
280 | * Check manifest param on callable. |
||
281 | * |
||
282 | * @param string $name |
||
283 | * @param string $plugin |
||
284 | * @param mixed $callback |
||
285 | * @return bool |
||
286 | */ |
||
287 | protected static function _isCallablePluginData($name, $plugin, $callback) |
||
298 | } |
||
299 |