namespacing: \Shaarli\Plugin\PluginManager
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
This commit is contained in:
parent
349b014401
commit
e185038834
22 changed files with 65 additions and 41 deletions
|
@ -1,4 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace Shaarli\Plugin;
|
||||||
|
|
||||||
|
use Shaarli\Config\ConfigManager;
|
||||||
|
use Shaarli\Plugin\Exception\PluginFileNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PluginManager
|
* Class PluginManager
|
||||||
|
@ -9,12 +13,14 @@ class PluginManager
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* List of authorized plugins from configuration file.
|
* List of authorized plugins from configuration file.
|
||||||
|
*
|
||||||
* @var array $authorizedPlugins
|
* @var array $authorizedPlugins
|
||||||
*/
|
*/
|
||||||
private $authorizedPlugins;
|
private $authorizedPlugins;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of loaded plugins.
|
* List of loaded plugins.
|
||||||
|
*
|
||||||
* @var array $loadedPlugins
|
* @var array $loadedPlugins
|
||||||
*/
|
*/
|
||||||
private $loadedPlugins = array();
|
private $loadedPlugins = array();
|
||||||
|
@ -31,12 +37,14 @@ class PluginManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugins subdirectory.
|
* Plugins subdirectory.
|
||||||
|
*
|
||||||
* @var string $PLUGINS_PATH
|
* @var string $PLUGINS_PATH
|
||||||
*/
|
*/
|
||||||
public static $PLUGINS_PATH = 'plugins';
|
public static $PLUGINS_PATH = 'plugins';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugins meta files extension.
|
* Plugins meta files extension.
|
||||||
|
*
|
||||||
* @var string $META_EXT
|
* @var string $META_EXT
|
||||||
*/
|
*/
|
||||||
public static $META_EXT = 'meta';
|
public static $META_EXT = 'meta';
|
||||||
|
@ -118,7 +126,7 @@ public function executeHooks($hook, &$data, $params = array())
|
||||||
* @param string $pluginName plugin's name.
|
* @param string $pluginName plugin's name.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws PluginFileNotFoundException - plugin files not found.
|
* @throws \Shaarli\Plugin\Exception\PluginFileNotFoundException - plugin files not found.
|
||||||
*/
|
*/
|
||||||
private function loadPlugin($dir, $pluginName)
|
private function loadPlugin($dir, $pluginName)
|
||||||
{
|
{
|
||||||
|
@ -223,22 +231,3 @@ public function getErrors()
|
||||||
return $this->errors;
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
23
application/plugin/exception/PluginFileNotFoundException.php
Normal file
23
application/plugin/exception/PluginFileNotFoundException.php
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -46,6 +46,8 @@
|
||||||
"Shaarli\\Feed\\": "application/feed",
|
"Shaarli\\Feed\\": "application/feed",
|
||||||
"Shaarli\\Http\\": "application/http",
|
"Shaarli\\Http\\": "application/http",
|
||||||
"Shaarli\\Netscape\\": "application/netscape",
|
"Shaarli\\Netscape\\": "application/netscape",
|
||||||
|
"Shaarli\\Plugin\\": "application/plugin",
|
||||||
|
"Shaarli\\Plugin\\Exception\\": "application/plugin/exception",
|
||||||
"Shaarli\\Render\\": "application/render",
|
"Shaarli\\Render\\": "application/render",
|
||||||
"Shaarli\\Security\\": "application/security",
|
"Shaarli\\Security\\": "application/security",
|
||||||
"Shaarli\\Updater\\": "application/updater",
|
"Shaarli\\Updater\\": "application/updater",
|
||||||
|
|
|
@ -65,7 +65,6 @@
|
||||||
require_once 'application/FileUtils.php';
|
require_once 'application/FileUtils.php';
|
||||||
require_once 'application/TimeZone.php';
|
require_once 'application/TimeZone.php';
|
||||||
require_once 'application/Utils.php';
|
require_once 'application/Utils.php';
|
||||||
require_once 'application/PluginManager.php';
|
|
||||||
|
|
||||||
use \Shaarli\ApplicationUtils;
|
use \Shaarli\ApplicationUtils;
|
||||||
use \Shaarli\Bookmark\Exception\LinkNotFoundException;
|
use \Shaarli\Bookmark\Exception\LinkNotFoundException;
|
||||||
|
@ -76,6 +75,7 @@
|
||||||
use \Shaarli\History;
|
use \Shaarli\History;
|
||||||
use \Shaarli\Languages;
|
use \Shaarli\Languages;
|
||||||
use \Shaarli\Netscape\NetscapeBookmarkUtils;
|
use \Shaarli\Netscape\NetscapeBookmarkUtils;
|
||||||
|
use \Shaarli\Plugin\PluginManager;
|
||||||
use \Shaarli\Render\PageBuilder;
|
use \Shaarli\Render\PageBuilder;
|
||||||
use \Shaarli\Render\ThemeUtils;
|
use \Shaarli\Render\ThemeUtils;
|
||||||
use \Shaarli\Router;
|
use \Shaarli\Router;
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
* Add an icon in the link list for archive.org.
|
* Add an icon in the link list for archive.org.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add archive.org icon to link_plugin when rendering linklist.
|
* Add archive.org icon to link_plugin when rendering linklist.
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
use Shaarli\Router;
|
use Shaarli\Router;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
use Shaarli\Router;
|
use Shaarli\Router;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
use Shaarli\Router;
|
use Shaarli\Router;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
* Adds tracking code on each page.
|
* Adds tracking code on each page.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization function.
|
* Initialization function.
|
||||||
* It will be called when the plugin is loaded.
|
* It will be called when the plugin is loaded.
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
* Note: this plugin adds jQuery.
|
* Note: this plugin adds jQuery.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
use Shaarli\Router;
|
use Shaarli\Router;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
use pubsubhubbub\publisher\Publisher;
|
use pubsubhubbub\publisher\Publisher;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Feed\FeedBuilder;
|
use Shaarli\Feed\FeedBuilder;
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
use Shaarli\Router;
|
use Shaarli\Router;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
* Display a QRCode icon in link list.
|
* Display a QRCode icon in link list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
use Shaarli\Router;
|
use Shaarli\Router;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
require_once 'WallabagInstance.php';
|
require_once 'WallabagInstance.php';
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init function, return an error if the server is not set.
|
* Init function, return an error if the server is not set.
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace Shaarli\Plugin;
|
||||||
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
|
||||||
/**
|
|
||||||
* Plugin Manager tests
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once 'application/PluginManager.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for Plugins
|
* Unit tests for Plugins
|
||||||
*/
|
*/
|
||||||
class PluginManagerTest extends PHPUnit_Framework_TestCase
|
class PluginManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Path to tests plugin.
|
* Path to tests plugin.
|
||||||
|
|
|
@ -1,19 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
use Shaarli\Plugin\PluginManager;
|
||||||
* PluginPlayvideosTest.php
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Shaarli\Router;
|
use Shaarli\Router;
|
||||||
|
|
||||||
require_once 'plugins/addlink_toolbar/addlink_toolbar.php';
|
require_once 'plugins/addlink_toolbar/addlink_toolbar.php';
|
||||||
require_once 'application/Router.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PluginAddlinkTest
|
|
||||||
* Unit test for the Addlink toolbar plugin
|
* Unit test for the Addlink toolbar plugin
|
||||||
*/
|
*/
|
||||||
class PluginAddlinkTest extends PHPUnit_Framework_TestCase
|
class PluginAddlinkTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Reset plugin path.
|
* Reset plugin path.
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
* PluginArchiveorgTest.php
|
* PluginArchiveorgTest.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
|
|
||||||
require_once 'plugins/archiveorg/archiveorg.php';
|
require_once 'plugins/archiveorg/archiveorg.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use Shaarli\Bookmark\LinkDB;
|
use Shaarli\Bookmark\LinkDB;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
|
|
||||||
require_once 'plugins/isso/isso.php';
|
require_once 'plugins/isso/isso.php';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PluginMarkdownTest.php
|
* PluginMarkdownTest.php
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* PluginPlayvideosTest.php
|
* PluginPlayvideosTest.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
use Shaarli\Router;
|
use Shaarli\Router;
|
||||||
|
|
||||||
require_once 'plugins/playvideos/playvideos.php';
|
require_once 'plugins/playvideos/playvideos.php';
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
use Shaarli\Router;
|
use Shaarli\Router;
|
||||||
|
|
||||||
require_once 'plugins/pubsubhubbub/pubsubhubbub.php';
|
require_once 'plugins/pubsubhubbub/pubsubhubbub.php';
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* PluginQrcodeTest.php
|
* PluginQrcodeTest.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
use Shaarli\Router;
|
use Shaarli\Router;
|
||||||
|
|
||||||
require_once 'plugins/qrcode/qrcode.php';
|
require_once 'plugins/qrcode/qrcode.php';
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
use Shaarli\Plugin\PluginManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PluginWallabagTest.php.php
|
* PluginWallabagTest.php.php
|
||||||
|
@ -11,7 +12,7 @@
|
||||||
* Class PluginWallabagTest
|
* Class PluginWallabagTest
|
||||||
* Unit test for the Wallabag plugin
|
* Unit test for the Wallabag plugin
|
||||||
*/
|
*/
|
||||||
class PluginWallabagTest extends PHPUnit_Framework_TestCase
|
class PluginWallabagTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Reset plugin path
|
* Reset plugin path
|
||||||
|
|
Loading…
Reference in a new issue