diff options
Diffstat (limited to 'application/PluginManager.php')
-rw-r--r-- | application/PluginManager.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/application/PluginManager.php b/application/PluginManager.php index 1e132a7f..59ece4fa 100644 --- a/application/PluginManager.php +++ b/application/PluginManager.php | |||
@@ -25,6 +25,11 @@ class PluginManager | |||
25 | protected $conf; | 25 | protected $conf; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * @var array List of plugin errors. | ||
29 | */ | ||
30 | protected $errors; | ||
31 | |||
32 | /** | ||
28 | * Plugins subdirectory. | 33 | * Plugins subdirectory. |
29 | * @var string $PLUGINS_PATH | 34 | * @var string $PLUGINS_PATH |
30 | */ | 35 | */ |
@@ -44,6 +49,7 @@ class PluginManager | |||
44 | public function __construct(&$conf) | 49 | public function __construct(&$conf) |
45 | { | 50 | { |
46 | $this->conf = $conf; | 51 | $this->conf = $conf; |
52 | $this->errors = array(); | ||
47 | } | 53 | } |
48 | 54 | ||
49 | /** | 55 | /** |
@@ -106,6 +112,7 @@ class PluginManager | |||
106 | 112 | ||
107 | /** | 113 | /** |
108 | * Load a single plugin from its files. | 114 | * Load a single plugin from its files. |
115 | * Call the init function if it exists, and collect errors. | ||
109 | * Add them in $loadedPlugins if successful. | 116 | * Add them in $loadedPlugins if successful. |
110 | * | 117 | * |
111 | * @param string $dir plugin's directory. | 118 | * @param string $dir plugin's directory. |
@@ -128,6 +135,14 @@ class PluginManager | |||
128 | $conf = $this->conf; | 135 | $conf = $this->conf; |
129 | include_once $pluginFilePath; | 136 | include_once $pluginFilePath; |
130 | 137 | ||
138 | $initFunction = $pluginName . '_init'; | ||
139 | if (function_exists($initFunction)) { | ||
140 | $errors = call_user_func($initFunction, $this->conf); | ||
141 | if (!empty($errors)) { | ||
142 | $this->errors = array_merge($this->errors, $errors); | ||
143 | } | ||
144 | } | ||
145 | |||
131 | $this->loadedPlugins[] = $pluginName; | 146 | $this->loadedPlugins[] = $pluginName; |
132 | } | 147 | } |
133 | 148 | ||
@@ -195,6 +210,16 @@ class PluginManager | |||
195 | 210 | ||
196 | return $metaData; | 211 | return $metaData; |
197 | } | 212 | } |
213 | |||
214 | /** | ||
215 | * Return the list of encountered errors. | ||
216 | * | ||
217 | * @return array List of errors (empty array if none exists). | ||
218 | */ | ||
219 | public function getErrors() | ||
220 | { | ||
221 | return $this->errors; | ||
222 | } | ||
198 | } | 223 | } |
199 | 224 | ||
200 | /** | 225 | /** |