]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
namespacing: \Shaarli\Plugin\PluginManager
authorVirtualTam <virtualtam@flibidi.net>
Mon, 3 Dec 2018 23:26:50 +0000 (00:26 +0100)
committerVirtualTam <virtualtam@flibidi.net>
Sat, 12 Jan 2019 22:11:19 +0000 (23:11 +0100)
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
22 files changed:
application/plugin/PluginManager.php [moved from application/PluginManager.php with 87% similarity]
application/plugin/exception/PluginFileNotFoundException.php [new file with mode: 0644]
composer.json
index.php
plugins/archiveorg/archiveorg.php
plugins/demo_plugin/demo_plugin.php
plugins/isso/isso.php
plugins/markdown/markdown.php
plugins/piwik/piwik.php
plugins/playvideos/playvideos.php
plugins/pubsubhubbub/pubsubhubbub.php
plugins/qrcode/qrcode.php
plugins/wallabag/wallabag.php
tests/PluginManagerTest.php
tests/plugins/PluginAddlinkTest.php
tests/plugins/PluginArchiveorgTest.php
tests/plugins/PluginIssoTest.php
tests/plugins/PluginMarkdownTest.php
tests/plugins/PluginPlayvideosTest.php
tests/plugins/PluginPubsubhubbubTest.php
tests/plugins/PluginQrcodeTest.php
tests/plugins/PluginWallabagTest.php

similarity index 87%
rename from application/PluginManager.php
rename to application/plugin/PluginManager.php
index 1ed4db4b30c09448227d028caf484a699bb0265a..f7b24a8e88c979031873ee1a8a59fe88503c4bf5 100644 (file)
@@ -1,4 +1,8 @@
 <?php
+namespace Shaarli\Plugin;
+
+use Shaarli\Config\ConfigManager;
+use Shaarli\Plugin\Exception\PluginFileNotFoundException;
 
 /**
  * Class PluginManager
@@ -9,12 +13,14 @@ class PluginManager
 {
     /**
      * List of authorized plugins from configuration file.
+     *
      * @var array $authorizedPlugins
      */
     private $authorizedPlugins;
 
     /**
      * List of loaded plugins.
+     *
      * @var array $loadedPlugins
      */
     private $loadedPlugins = array();
@@ -31,12 +37,14 @@ class PluginManager
 
     /**
      * Plugins subdirectory.
+     *
      * @var string $PLUGINS_PATH
      */
     public static $PLUGINS_PATH = 'plugins';
 
     /**
      * Plugins meta files extension.
+     *
      * @var string $META_EXT
      */
     public static $META_EXT = 'meta';
@@ -84,9 +92,9 @@ class PluginManager
     /**
      * Execute all plugins registered hook.
      *
-     * @param string        $hook   name of the hook to trigger.
-     * @param array         $data   list of data to manipulate passed by reference.
-     * @param array         $params additional parameters such as page target.
+     * @param string $hook   name of the hook to trigger.
+     * @param array  $data   list of data to manipulate passed by reference.
+     * @param array  $params additional parameters such as page target.
      *
      * @return void
      */
@@ -118,7 +126,7 @@ class PluginManager
      * @param string $pluginName plugin's name.
      *
      * @return void
-     * @throws PluginFileNotFoundException - plugin files not found.
+     * @throws \Shaarli\Plugin\Exception\PluginFileNotFoundException - plugin files not found.
      */
     private function loadPlugin($dir, $pluginName)
     {
@@ -204,8 +212,8 @@ class PluginManager
 
                 $metaData[$plugin]['parameters'][$param]['value'] = '';
                 // Optional parameter description in parameter.PARAM_NAME=
-                if (isset($metaData[$plugin]['parameter.'. $param])) {
-                    $metaData[$plugin]['parameters'][$param]['desc'] = t($metaData[$plugin]['parameter.'. $param]);
+                if (isset($metaData[$plugin]['parameter.' . $param])) {
+                    $metaData[$plugin]['parameters'][$param]['desc'] = t($metaData[$plugin]['parameter.' . $param]);
                 }
             }
         }
@@ -223,22 +231,3 @@ class PluginManager
         return $this->errors;
     }
 }
-
-/**
- * Class PluginFileNotFoundException
- *
- * Raise when plugin files can't be found.
- */
-class PluginFileNotFoundException extends Exception
-{
-    /**
-     * Construct exception with plugin name.
-     * Generate message.
-     *
-     * @param string $pluginName name of the plugin not found
-     */
-    public function __construct($pluginName)
-    {
-        $this->message = sprintf(t('Plugin "%s" files not found.'), $pluginName);
-    }
-}
diff --git a/application/plugin/exception/PluginFileNotFoundException.php b/application/plugin/exception/PluginFileNotFoundException.php
new file mode 100644 (file)
index 0000000..e5386f0
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+namespace Shaarli\Plugin\Exception;
+
+use Exception;
+
+/**
+ * Class PluginFileNotFoundException
+ *
+ * Raise when plugin files can't be found.
+ */
+class PluginFileNotFoundException extends Exception
+{
+    /**
+     * Construct exception with plugin name.
+     * Generate message.
+     *
+     * @param string $pluginName name of the plugin not found
+     */
+    public function __construct($pluginName)
+    {
+        $this->message = sprintf(t('Plugin "%s" files not found.'), $pluginName);
+    }
+}
index c1f47317b8bd92058cc916631e520bb9efd9a7a4..a2df466a54fe0ab3abe6c2facd51ff02a5cae073 100644 (file)
@@ -46,6 +46,8 @@
             "Shaarli\\Feed\\": "application/feed",
             "Shaarli\\Http\\": "application/http",
             "Shaarli\\Netscape\\": "application/netscape",
+            "Shaarli\\Plugin\\": "application/plugin",
+            "Shaarli\\Plugin\\Exception\\": "application/plugin/exception",
             "Shaarli\\Render\\": "application/render",
             "Shaarli\\Security\\": "application/security",
             "Shaarli\\Updater\\": "application/updater",
index bff8e8ff14f24f5de02eb7be20ef8e5901afb48d..633ab89e6386e90eaa02f76d5a1880cb9366dccb 100644 (file)
--- a/index.php
+++ b/index.php
@@ -65,7 +65,6 @@ require_once 'application/updater/UpdaterUtils.php';
 require_once 'application/FileUtils.php';
 require_once 'application/TimeZone.php';
 require_once 'application/Utils.php';
-require_once 'application/PluginManager.php';
 
 use \Shaarli\ApplicationUtils;
 use \Shaarli\Bookmark\Exception\LinkNotFoundException;
@@ -76,6 +75,7 @@ use \Shaarli\Feed\FeedBuilder;
 use \Shaarli\History;
 use \Shaarli\Languages;
 use \Shaarli\Netscape\NetscapeBookmarkUtils;
+use \Shaarli\Plugin\PluginManager;
 use \Shaarli\Render\PageBuilder;
 use \Shaarli\Render\ThemeUtils;
 use \Shaarli\Router;
index 5dcea5a647930b43d6226fc8033f9e51408db67c..0ee1c73c9333ef0fd9635db3ededbc64fb44521e 100644 (file)
@@ -5,6 +5,8 @@
  * Add an icon in the link list for archive.org.
  */
 
+use Shaarli\Plugin\PluginManager;
+
 /**
  * Add archive.org icon to link_plugin when rendering linklist.
  *
index 94ce38f826475fa23fccfbdd5e736dea4c6e28f2..95ea7fe2d029767f16c000d1672e9aa0bacf4cd4 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 use Shaarli\Config\ConfigManager;
+use Shaarli\Plugin\PluginManager;
 use Shaarli\Router;
 
 /**
index 9bdd5909bc49edc35f029a7a13497a928e5a0279..dab75dd55c5c0b06789da06e688664ef97256b54 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 use Shaarli\Config\ConfigManager;
+use Shaarli\Plugin\PluginManager;
 use Shaarli\Router;
 
 /**
index 9928a4885e1f3616a7251da4dda723260315984f..628970d626ff4064b0daecc0b97fd40c855d3551 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 use Shaarli\Config\ConfigManager;
+use Shaarli\Plugin\PluginManager;
 use Shaarli\Router;
 
 /*
index ca00c2be71f33dd566be43fb2fb2f791d41e26cf..17b1aeccf9926a2a908350ce9a3c448f285f641d 100644 (file)
@@ -4,6 +4,8 @@
  * Adds tracking code on each page.
  */
 
+use Shaarli\Plugin\PluginManager;
+
 /**
  * Initialization function.
  * It will be called when the plugin is loaded.
index bb5b9e98caa280dd0394516a073b05463abb18ac..0341ed593abd19cb0afb5db4a092e4bb34944dd6 100644 (file)
@@ -6,6 +6,7 @@
  * Note: this plugin adds jQuery.
  */
 
+use Shaarli\Plugin\PluginManager;
 use Shaarli\Router;
 
 /**
index a7bd34c1926d6f012751b33a47ec4ed6514874ae..2878c0505be296b486ab2b9ee4547a2851c7986b 100644 (file)
@@ -12,6 +12,7 @@
 use pubsubhubbub\publisher\Publisher;
 use Shaarli\Config\ConfigManager;
 use Shaarli\Feed\FeedBuilder;
+use Shaarli\Plugin\PluginManager;
 use Shaarli\Router;
 
 /**
index 21908cee6817b33d1094651e9c58d7de910b260d..34eef8be3fe88ca23c0f00cdeaa9c444795075be 100644 (file)
@@ -5,6 +5,7 @@
  * Display a QRCode icon in link list.
  */
 
+use Shaarli\Plugin\PluginManager;
 use Shaarli\Router;
 
 /**
index a6476c71c893b0b9f7b2fadef9e8610a86b807be..5ba1611d539b1e117e8817f690718cdf007655da 100644 (file)
@@ -6,6 +6,7 @@
 
 require_once 'WallabagInstance.php';
 use Shaarli\Config\ConfigManager;
+use Shaarli\Plugin\PluginManager;
 
 /**
  * Init function, return an error if the server is not set.
index 01de959c5266bb9e877f7e425e5a5af9e2cc673d..71761ac17db62f18eb199f4f85e32774b4ae2cf4 100644 (file)
@@ -1,16 +1,12 @@
 <?php
-use Shaarli\Config\ConfigManager;
+namespace Shaarli\Plugin;
 
-/**
- * Plugin Manager tests
- */
-
-require_once 'application/PluginManager.php';
+use Shaarli\Config\ConfigManager;
 
 /**
  * Unit tests for Plugins
  */
-class PluginManagerTest extends PHPUnit_Framework_TestCase
+class PluginManagerTest extends \PHPUnit\Framework\TestCase
 {
     /**
      * Path to tests plugin.
index f6fea7afb3c3dcccb11d7e17c62d1039d976ab6c..e0a0107d5a485fcf5e5c36e88eb5a318095e40d8 100644 (file)
@@ -1,19 +1,14 @@
 <?php
 
-/**
- * PluginPlayvideosTest.php
- */
-
+use Shaarli\Plugin\PluginManager;
 use Shaarli\Router;
 
 require_once 'plugins/addlink_toolbar/addlink_toolbar.php';
-require_once 'application/Router.php';
 
 /**
- * Class PluginAddlinkTest
  * Unit test for the Addlink toolbar plugin
  */
-class PluginAddlinkTest extends PHPUnit_Framework_TestCase
+class PluginAddlinkTest extends \PHPUnit\Framework\TestCase
 {
     /**
      * Reset plugin path.
index fecd5f2c21488b3cf35390b663879766c0a1a0e8..d06bfa59eec45bb32f2cd13b80a9414b14d709f4 100644 (file)
@@ -4,6 +4,8 @@
  * PluginArchiveorgTest.php
  */
 
+use Shaarli\Plugin\PluginManager;
+
 require_once 'plugins/archiveorg/archiveorg.php';
 
 /**
index f5fa1daacbc81f5ed3296b811e060d2f2e63a87c..7aee21974066d74bf51d290fd88341c4992ba9f0 100644 (file)
@@ -2,6 +2,7 @@
 
 use Shaarli\Bookmark\LinkDB;
 use Shaarli\Config\ConfigManager;
+use Shaarli\Plugin\PluginManager;
 
 require_once 'plugins/isso/isso.php';
 
index d695186620cfc8f0a7188e8ccad69cb467565e90..90a19e7b3862212bab7fea8f23e79139c850b5b7 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 use Shaarli\Config\ConfigManager;
+use Shaarli\Plugin\PluginManager;
 
 /**
  * PluginMarkdownTest.php
index 7ee924004a983c549bed06c1f614d75eea4610e1..aa3ad14341809101a5f885506cc13458362bc057 100644 (file)
@@ -4,6 +4,7 @@
  * PluginPlayvideosTest.php
  */
 
+use Shaarli\Plugin\PluginManager;
 use Shaarli\Router;
 
 require_once 'plugins/playvideos/playvideos.php';
index 75f146f2d8154a3d6494e010056c3a79f35dc76a..4680513eba0cef15f50d7075af937295938c02e9 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 use Shaarli\Config\ConfigManager;
+use Shaarli\Plugin\PluginManager;
 use Shaarli\Router;
 
 require_once 'plugins/pubsubhubbub/pubsubhubbub.php';
index 419965eb08c3b15d27041d7ab25f5036698d052a..325e3109c8c63b012fb4b573792cfebe95f7a0f2 100644 (file)
@@ -3,6 +3,7 @@
  * PluginQrcodeTest.php
  */
 
+use Shaarli\Plugin\PluginManager;
 use Shaarli\Router;
 
 require_once 'plugins/qrcode/qrcode.php';
index 76b7887e53e1443272527518d50a72f5eb4b420e..4e445efb225e148caec09345967cc3f4983ae78f 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 use Shaarli\Config\ConfigManager;
+use Shaarli\Plugin\PluginManager;
 
 /**
  * PluginWallabagTest.php.php
@@ -11,7 +12,7 @@ require_once 'plugins/wallabag/wallabag.php';
  * Class PluginWallabagTest
  * Unit test for the Wallabag plugin
  */
-class PluginWallabagTest extends PHPUnit_Framework_TestCase
+class PluginWallabagTest extends \PHPUnit\Framework\TestCase
 {
     /**
      * Reset plugin path