aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2018-12-04 00:26:50 +0100
committerVirtualTam <virtualtam@flibidi.net>2019-01-12 23:11:19 +0100
commite1850388348d4bfdf463a5aa341bc470da79cf32 (patch)
treea97cfd137b545e7b3ada43c4b5bfe143bd494948
parent349b0144011e25f2b1a727b1d28d49d55b3b2ebb (diff)
downloadShaarli-e1850388348d4bfdf463a5aa341bc470da79cf32.tar.gz
Shaarli-e1850388348d4bfdf463a5aa341bc470da79cf32.tar.zst
Shaarli-e1850388348d4bfdf463a5aa341bc470da79cf32.zip
namespacing: \Shaarli\Plugin\PluginManager
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
-rw-r--r--application/plugin/PluginManager.php (renamed from application/PluginManager.php)39
-rw-r--r--application/plugin/exception/PluginFileNotFoundException.php23
-rw-r--r--composer.json2
-rw-r--r--index.php2
-rw-r--r--plugins/archiveorg/archiveorg.php2
-rw-r--r--plugins/demo_plugin/demo_plugin.php1
-rw-r--r--plugins/isso/isso.php1
-rw-r--r--plugins/markdown/markdown.php1
-rw-r--r--plugins/piwik/piwik.php2
-rw-r--r--plugins/playvideos/playvideos.php1
-rw-r--r--plugins/pubsubhubbub/pubsubhubbub.php1
-rw-r--r--plugins/qrcode/qrcode.php1
-rw-r--r--plugins/wallabag/wallabag.php1
-rw-r--r--tests/PluginManagerTest.php10
-rw-r--r--tests/plugins/PluginAddlinkTest.php9
-rw-r--r--tests/plugins/PluginArchiveorgTest.php2
-rw-r--r--tests/plugins/PluginIssoTest.php1
-rw-r--r--tests/plugins/PluginMarkdownTest.php1
-rw-r--r--tests/plugins/PluginPlayvideosTest.php1
-rw-r--r--tests/plugins/PluginPubsubhubbubTest.php1
-rw-r--r--tests/plugins/PluginQrcodeTest.php1
-rw-r--r--tests/plugins/PluginWallabagTest.php3
22 files changed, 65 insertions, 41 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}
diff --git a/composer.json b/composer.json
index c1f47317..a2df466a 100644
--- a/composer.json
+++ b/composer.json
@@ -46,6 +46,8 @@
46 "Shaarli\\Feed\\": "application/feed", 46 "Shaarli\\Feed\\": "application/feed",
47 "Shaarli\\Http\\": "application/http", 47 "Shaarli\\Http\\": "application/http",
48 "Shaarli\\Netscape\\": "application/netscape", 48 "Shaarli\\Netscape\\": "application/netscape",
49 "Shaarli\\Plugin\\": "application/plugin",
50 "Shaarli\\Plugin\\Exception\\": "application/plugin/exception",
49 "Shaarli\\Render\\": "application/render", 51 "Shaarli\\Render\\": "application/render",
50 "Shaarli\\Security\\": "application/security", 52 "Shaarli\\Security\\": "application/security",
51 "Shaarli\\Updater\\": "application/updater", 53 "Shaarli\\Updater\\": "application/updater",
diff --git a/index.php b/index.php
index bff8e8ff..633ab89e 100644
--- a/index.php
+++ b/index.php
@@ -65,7 +65,6 @@ require_once 'application/updater/UpdaterUtils.php';
65require_once 'application/FileUtils.php'; 65require_once 'application/FileUtils.php';
66require_once 'application/TimeZone.php'; 66require_once 'application/TimeZone.php';
67require_once 'application/Utils.php'; 67require_once 'application/Utils.php';
68require_once 'application/PluginManager.php';
69 68
70use \Shaarli\ApplicationUtils; 69use \Shaarli\ApplicationUtils;
71use \Shaarli\Bookmark\Exception\LinkNotFoundException; 70use \Shaarli\Bookmark\Exception\LinkNotFoundException;
@@ -76,6 +75,7 @@ use \Shaarli\Feed\FeedBuilder;
76use \Shaarli\History; 75use \Shaarli\History;
77use \Shaarli\Languages; 76use \Shaarli\Languages;
78use \Shaarli\Netscape\NetscapeBookmarkUtils; 77use \Shaarli\Netscape\NetscapeBookmarkUtils;
78use \Shaarli\Plugin\PluginManager;
79use \Shaarli\Render\PageBuilder; 79use \Shaarli\Render\PageBuilder;
80use \Shaarli\Render\ThemeUtils; 80use \Shaarli\Render\ThemeUtils;
81use \Shaarli\Router; 81use \Shaarli\Router;
diff --git a/plugins/archiveorg/archiveorg.php b/plugins/archiveorg/archiveorg.php
index 5dcea5a6..0ee1c73c 100644
--- a/plugins/archiveorg/archiveorg.php
+++ b/plugins/archiveorg/archiveorg.php
@@ -5,6 +5,8 @@
5 * Add an icon in the link list for archive.org. 5 * Add an icon in the link list for archive.org.
6 */ 6 */
7 7
8use Shaarli\Plugin\PluginManager;
9
8/** 10/**
9 * Add archive.org icon to link_plugin when rendering linklist. 11 * Add archive.org icon to link_plugin when rendering linklist.
10 * 12 *
diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php
index 94ce38f8..95ea7fe2 100644
--- a/plugins/demo_plugin/demo_plugin.php
+++ b/plugins/demo_plugin/demo_plugin.php
@@ -15,6 +15,7 @@
15 */ 15 */
16 16
17use Shaarli\Config\ConfigManager; 17use Shaarli\Config\ConfigManager;
18use Shaarli\Plugin\PluginManager;
18use Shaarli\Router; 19use Shaarli\Router;
19 20
20/** 21/**
diff --git a/plugins/isso/isso.php b/plugins/isso/isso.php
index 9bdd5909..dab75dd5 100644
--- a/plugins/isso/isso.php
+++ b/plugins/isso/isso.php
@@ -5,6 +5,7 @@
5 */ 5 */
6 6
7use Shaarli\Config\ConfigManager; 7use Shaarli\Config\ConfigManager;
8use Shaarli\Plugin\PluginManager;
8use Shaarli\Router; 9use Shaarli\Router;
9 10
10/** 11/**
diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php
index 9928a488..628970d6 100644
--- a/plugins/markdown/markdown.php
+++ b/plugins/markdown/markdown.php
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9use Shaarli\Config\ConfigManager; 9use Shaarli\Config\ConfigManager;
10use Shaarli\Plugin\PluginManager;
10use Shaarli\Router; 11use Shaarli\Router;
11 12
12/* 13/*
diff --git a/plugins/piwik/piwik.php b/plugins/piwik/piwik.php
index ca00c2be..17b1aecc 100644
--- a/plugins/piwik/piwik.php
+++ b/plugins/piwik/piwik.php
@@ -4,6 +4,8 @@
4 * Adds tracking code on each page. 4 * Adds tracking code on each page.
5 */ 5 */
6 6
7use Shaarli\Plugin\PluginManager;
8
7/** 9/**
8 * Initialization function. 10 * Initialization function.
9 * It will be called when the plugin is loaded. 11 * It will be called when the plugin is loaded.
diff --git a/plugins/playvideos/playvideos.php b/plugins/playvideos/playvideos.php
index bb5b9e98..0341ed59 100644
--- a/plugins/playvideos/playvideos.php
+++ b/plugins/playvideos/playvideos.php
@@ -6,6 +6,7 @@
6 * Note: this plugin adds jQuery. 6 * Note: this plugin adds jQuery.
7 */ 7 */
8 8
9use Shaarli\Plugin\PluginManager;
9use Shaarli\Router; 10use Shaarli\Router;
10 11
11/** 12/**
diff --git a/plugins/pubsubhubbub/pubsubhubbub.php b/plugins/pubsubhubbub/pubsubhubbub.php
index a7bd34c1..2878c050 100644
--- a/plugins/pubsubhubbub/pubsubhubbub.php
+++ b/plugins/pubsubhubbub/pubsubhubbub.php
@@ -12,6 +12,7 @@
12use pubsubhubbub\publisher\Publisher; 12use pubsubhubbub\publisher\Publisher;
13use Shaarli\Config\ConfigManager; 13use Shaarli\Config\ConfigManager;
14use Shaarli\Feed\FeedBuilder; 14use Shaarli\Feed\FeedBuilder;
15use Shaarli\Plugin\PluginManager;
15use Shaarli\Router; 16use Shaarli\Router;
16 17
17/** 18/**
diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php
index 21908cee..34eef8be 100644
--- a/plugins/qrcode/qrcode.php
+++ b/plugins/qrcode/qrcode.php
@@ -5,6 +5,7 @@
5 * Display a QRCode icon in link list. 5 * Display a QRCode icon in link list.
6 */ 6 */
7 7
8use Shaarli\Plugin\PluginManager;
8use Shaarli\Router; 9use Shaarli\Router;
9 10
10/** 11/**
diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php
index a6476c71..5ba1611d 100644
--- a/plugins/wallabag/wallabag.php
+++ b/plugins/wallabag/wallabag.php
@@ -6,6 +6,7 @@
6 6
7require_once 'WallabagInstance.php'; 7require_once 'WallabagInstance.php';
8use Shaarli\Config\ConfigManager; 8use Shaarli\Config\ConfigManager;
9use Shaarli\Plugin\PluginManager;
9 10
10/** 11/**
11 * Init function, return an error if the server is not set. 12 * Init function, return an error if the server is not set.
diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php
index 01de959c..71761ac1 100644
--- a/tests/PluginManagerTest.php
+++ b/tests/PluginManagerTest.php
@@ -1,16 +1,12 @@
1<?php 1<?php
2use Shaarli\Config\ConfigManager; 2namespace Shaarli\Plugin;
3 3
4/** 4use Shaarli\Config\ConfigManager;
5 * Plugin Manager tests
6 */
7
8require_once 'application/PluginManager.php';
9 5
10/** 6/**
11 * Unit tests for Plugins 7 * Unit tests for Plugins
12 */ 8 */
13class PluginManagerTest extends PHPUnit_Framework_TestCase 9class PluginManagerTest extends \PHPUnit\Framework\TestCase
14{ 10{
15 /** 11 /**
16 * Path to tests plugin. 12 * Path to tests plugin.
diff --git a/tests/plugins/PluginAddlinkTest.php b/tests/plugins/PluginAddlinkTest.php
index f6fea7af..e0a0107d 100644
--- a/tests/plugins/PluginAddlinkTest.php
+++ b/tests/plugins/PluginAddlinkTest.php
@@ -1,19 +1,14 @@
1<?php 1<?php
2 2
3/** 3use Shaarli\Plugin\PluginManager;
4 * PluginPlayvideosTest.php
5 */
6
7use Shaarli\Router; 4use Shaarli\Router;
8 5
9require_once 'plugins/addlink_toolbar/addlink_toolbar.php'; 6require_once 'plugins/addlink_toolbar/addlink_toolbar.php';
10require_once 'application/Router.php';
11 7
12/** 8/**
13 * Class PluginAddlinkTest
14 * Unit test for the Addlink toolbar plugin 9 * Unit test for the Addlink toolbar plugin
15 */ 10 */
16class PluginAddlinkTest extends PHPUnit_Framework_TestCase 11class PluginAddlinkTest extends \PHPUnit\Framework\TestCase
17{ 12{
18 /** 13 /**
19 * Reset plugin path. 14 * Reset plugin path.
diff --git a/tests/plugins/PluginArchiveorgTest.php b/tests/plugins/PluginArchiveorgTest.php
index fecd5f2c..d06bfa59 100644
--- a/tests/plugins/PluginArchiveorgTest.php
+++ b/tests/plugins/PluginArchiveorgTest.php
@@ -4,6 +4,8 @@
4 * PluginArchiveorgTest.php 4 * PluginArchiveorgTest.php
5 */ 5 */
6 6
7use Shaarli\Plugin\PluginManager;
8
7require_once 'plugins/archiveorg/archiveorg.php'; 9require_once 'plugins/archiveorg/archiveorg.php';
8 10
9/** 11/**
diff --git a/tests/plugins/PluginIssoTest.php b/tests/plugins/PluginIssoTest.php
index f5fa1daa..7aee2197 100644
--- a/tests/plugins/PluginIssoTest.php
+++ b/tests/plugins/PluginIssoTest.php
@@ -2,6 +2,7 @@
2 2
3use Shaarli\Bookmark\LinkDB; 3use Shaarli\Bookmark\LinkDB;
4use Shaarli\Config\ConfigManager; 4use Shaarli\Config\ConfigManager;
5use Shaarli\Plugin\PluginManager;
5 6
6require_once 'plugins/isso/isso.php'; 7require_once 'plugins/isso/isso.php';
7 8
diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php
index d6951866..90a19e7b 100644
--- a/tests/plugins/PluginMarkdownTest.php
+++ b/tests/plugins/PluginMarkdownTest.php
@@ -1,5 +1,6 @@
1<?php 1<?php
2use Shaarli\Config\ConfigManager; 2use Shaarli\Config\ConfigManager;
3use Shaarli\Plugin\PluginManager;
3 4
4/** 5/**
5 * PluginMarkdownTest.php 6 * PluginMarkdownTest.php
diff --git a/tests/plugins/PluginPlayvideosTest.php b/tests/plugins/PluginPlayvideosTest.php
index 7ee92400..aa3ad143 100644
--- a/tests/plugins/PluginPlayvideosTest.php
+++ b/tests/plugins/PluginPlayvideosTest.php
@@ -4,6 +4,7 @@
4 * PluginPlayvideosTest.php 4 * PluginPlayvideosTest.php
5 */ 5 */
6 6
7use Shaarli\Plugin\PluginManager;
7use Shaarli\Router; 8use Shaarli\Router;
8 9
9require_once 'plugins/playvideos/playvideos.php'; 10require_once 'plugins/playvideos/playvideos.php';
diff --git a/tests/plugins/PluginPubsubhubbubTest.php b/tests/plugins/PluginPubsubhubbubTest.php
index 75f146f2..4680513e 100644
--- a/tests/plugins/PluginPubsubhubbubTest.php
+++ b/tests/plugins/PluginPubsubhubbubTest.php
@@ -1,5 +1,6 @@
1<?php 1<?php
2use Shaarli\Config\ConfigManager; 2use Shaarli\Config\ConfigManager;
3use Shaarli\Plugin\PluginManager;
3use Shaarli\Router; 4use Shaarli\Router;
4 5
5require_once 'plugins/pubsubhubbub/pubsubhubbub.php'; 6require_once 'plugins/pubsubhubbub/pubsubhubbub.php';
diff --git a/tests/plugins/PluginQrcodeTest.php b/tests/plugins/PluginQrcodeTest.php
index 419965eb..325e3109 100644
--- a/tests/plugins/PluginQrcodeTest.php
+++ b/tests/plugins/PluginQrcodeTest.php
@@ -3,6 +3,7 @@
3 * PluginQrcodeTest.php 3 * PluginQrcodeTest.php
4 */ 4 */
5 5
6use Shaarli\Plugin\PluginManager;
6use Shaarli\Router; 7use Shaarli\Router;
7 8
8require_once 'plugins/qrcode/qrcode.php'; 9require_once 'plugins/qrcode/qrcode.php';
diff --git a/tests/plugins/PluginWallabagTest.php b/tests/plugins/PluginWallabagTest.php
index 76b7887e..4e445efb 100644
--- a/tests/plugins/PluginWallabagTest.php
+++ b/tests/plugins/PluginWallabagTest.php
@@ -1,5 +1,6 @@
1<?php 1<?php
2use Shaarli\Config\ConfigManager; 2use Shaarli\Config\ConfigManager;
3use Shaarli\Plugin\PluginManager;
3 4
4/** 5/**
5 * PluginWallabagTest.php.php 6 * PluginWallabagTest.php.php
@@ -11,7 +12,7 @@ require_once 'plugins/wallabag/wallabag.php';
11 * Class PluginWallabagTest 12 * Class PluginWallabagTest
12 * Unit test for the Wallabag plugin 13 * Unit test for the Wallabag plugin
13 */ 14 */
14class PluginWallabagTest extends PHPUnit_Framework_TestCase 15class PluginWallabagTest extends \PHPUnit\Framework\TestCase
15{ 16{
16 /** 17 /**
17 * Reset plugin path 18 * Reset plugin path