aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/plugin/PluginManager.php (renamed from application/PluginManager.php)39
-rw-r--r--application/plugin/exception/PluginFileNotFoundException.php23
2 files changed, 37 insertions, 25 deletions
diff --git a/application/PluginManager.php b/application/plugin/PluginManager.php
index 1ed4db4b..f7b24a8e 100644
--- a/application/PluginManager.php
+++ b/application/plugin/PluginManager.php
@@ -1,4 +1,8 @@
1<?php 1<?php
2namespace Shaarli\Plugin;
3
4use Shaarli\Config\ConfigManager;
5use Shaarli\Plugin\Exception\PluginFileNotFoundException;
2 6
3/** 7/**
4 * Class PluginManager 8 * Class PluginManager
@@ -9,12 +13,14 @@ class PluginManager
9{ 13{
10 /** 14 /**
11 * List of authorized plugins from configuration file. 15 * List of authorized plugins from configuration file.
16 *
12 * @var array $authorizedPlugins 17 * @var array $authorizedPlugins
13 */ 18 */
14 private $authorizedPlugins; 19 private $authorizedPlugins;
15 20
16 /** 21 /**
17 * List of loaded plugins. 22 * List of loaded plugins.
23 *
18 * @var array $loadedPlugins 24 * @var array $loadedPlugins
19 */ 25 */
20 private $loadedPlugins = array(); 26 private $loadedPlugins = array();
@@ -31,12 +37,14 @@ class PluginManager
31 37
32 /** 38 /**
33 * Plugins subdirectory. 39 * Plugins subdirectory.
40 *
34 * @var string $PLUGINS_PATH 41 * @var string $PLUGINS_PATH
35 */ 42 */
36 public static $PLUGINS_PATH = 'plugins'; 43 public static $PLUGINS_PATH = 'plugins';
37 44
38 /** 45 /**
39 * Plugins meta files extension. 46 * Plugins meta files extension.
47 *
40 * @var string $META_EXT 48 * @var string $META_EXT
41 */ 49 */
42 public static $META_EXT = 'meta'; 50 public static $META_EXT = 'meta';
@@ -84,9 +92,9 @@ class PluginManager
84 /** 92 /**
85 * Execute all plugins registered hook. 93 * Execute all plugins registered hook.
86 * 94 *
87 * @param string $hook name of the hook to trigger. 95 * @param string $hook name of the hook to trigger.
88 * @param array $data list of data to manipulate passed by reference. 96 * @param array $data list of data to manipulate passed by reference.
89 * @param array $params additional parameters such as page target. 97 * @param array $params additional parameters such as page target.
90 * 98 *
91 * @return void 99 * @return void
92 */ 100 */
@@ -118,7 +126,7 @@ class PluginManager
118 * @param string $pluginName plugin's name. 126 * @param string $pluginName plugin's name.
119 * 127 *
120 * @return void 128 * @return void
121 * @throws PluginFileNotFoundException - plugin files not found. 129 * @throws \Shaarli\Plugin\Exception\PluginFileNotFoundException - plugin files not found.
122 */ 130 */
123 private function loadPlugin($dir, $pluginName) 131 private function loadPlugin($dir, $pluginName)
124 { 132 {
@@ -204,8 +212,8 @@ class PluginManager
204 212
205 $metaData[$plugin]['parameters'][$param]['value'] = ''; 213 $metaData[$plugin]['parameters'][$param]['value'] = '';
206 // Optional parameter description in parameter.PARAM_NAME= 214 // Optional parameter description in parameter.PARAM_NAME=
207 if (isset($metaData[$plugin]['parameter.'. $param])) { 215 if (isset($metaData[$plugin]['parameter.' . $param])) {
208 $metaData[$plugin]['parameters'][$param]['desc'] = t($metaData[$plugin]['parameter.'. $param]); 216 $metaData[$plugin]['parameters'][$param]['desc'] = t($metaData[$plugin]['parameter.' . $param]);
209 } 217 }
210 } 218 }
211 } 219 }
@@ -223,22 +231,3 @@ class PluginManager
223 return $this->errors; 231 return $this->errors;
224 } 232 }
225} 233}
226
227/**
228 * Class PluginFileNotFoundException
229 *
230 * Raise when plugin files can't be found.
231 */
232class PluginFileNotFoundException extends Exception
233{
234 /**
235 * Construct exception with plugin name.
236 * Generate message.
237 *
238 * @param string $pluginName name of the plugin not found
239 */
240 public function __construct($pluginName)
241 {
242 $this->message = sprintf(t('Plugin "%s" files not found.'), $pluginName);
243 }
244}
diff --git a/application/plugin/exception/PluginFileNotFoundException.php b/application/plugin/exception/PluginFileNotFoundException.php
new file mode 100644
index 00000000..e5386f02
--- /dev/null
+++ b/application/plugin/exception/PluginFileNotFoundException.php
@@ -0,0 +1,23 @@
1<?php
2namespace Shaarli\Plugin\Exception;
3
4use Exception;
5
6/**
7 * Class PluginFileNotFoundException
8 *
9 * Raise when plugin files can't be found.
10 */
11class PluginFileNotFoundException extends Exception
12{
13 /**
14 * Construct exception with plugin name.
15 * Generate message.
16 *
17 * @param string $pluginName name of the plugin not found
18 */
19 public function __construct($pluginName)
20 {
21 $this->message = sprintf(t('Plugin "%s" files not found.'), $pluginName);
22 }
23}