Source for file PluginManager.php
Documentation is available at PluginManager.php
* $Source: /cvsroot/svggrapher/svggrapher/mains/PluginManager.php,v $
* @version CVS: $Id: PluginManager.php,v 1.4 2007/10/23 09:22:53 geelweb Exp $
* @author Guillaume Luchet. <guillaume@geelweb.org>
* @copyright Copyright (c) 2007, Guillaume Luchet.
* @license http://opensource.org/licenses/bsd-license.php BSD License
* Path of the dataproviders plugins
if(!defined('SVGGRAPHER_PLUGINS_DATAPROVIDER')) {
define('SVGGRAPHER_PLUGINS_DATAPROVIDER', SVGGRAPHER_CLASS_PATH .
'/dataproviders');
* Path of the defs plugins
if(!defined('SVGGRAPHER_PLUGINS_DEFS')) {
define('SVGGRAPHER_PLUGINS_DEFS', SVGGRAPHER_CLASS_PATH .
'/defs');
* Path of the filters plugins
if(!defined('SVGGRAPHER_PLUGINS_FILTER')) {
define('SVGGRAPHER_PLUGINS_FILTER', SVGGRAPHER_CLASS_PATH .
'/defs');
* Path of the markers plugins
if(!defined('SVGGRAPHER_PLUGINS_MARKER')) {
define('SVGGRAPHER_PLUGINS_MARKER', SVGGRAPHER_CLASS_PATH .
'/defs');
* Path of the scripts plugins
if(!defined('SVGGRAPHER_PLUGINS_SCRIPT')) {
define('SVGGRAPHER_PLUGINS_SCRIPT', SVGGRAPHER_CLASS_PATH .
'/scripts');
* Path of the visuals plugins
if(!defined('SVGGRAPHER_PLUGINS_VISUAL')) {
define('SVGGRAPHER_PLUGINS_VISUAL', SVGGRAPHER_CLASS_PATH .
'/visuals');
* This class is composed of static method to manage the SvgGrapher plugins. The
* - bool incl(string, string) inlude a plugin file
* - string exist(string, string) check if a plugin exist
* - mixed execute(string, string [, $args]) execute a plugin function
* The two first parameters are always the plugin type (visual, dataprovider, etc) and
* @version $Id: PluginManager.php,v 1.4 2007/10/23 09:22:53 geelweb Exp $
* @copyright Copyright (c) 2007, Guillaume Luchet
* @author guillaume luchet <guillaume@geelweb.org>
* @license http://opensource.org/licenses/bsd-license.php BSD License
* Array of paths for plugins types.
static $pluginsPaths =
array(
'dataprovider' =>
SVGGRAPHER_PLUGINS_DATAPROVIDER,
'defs' =>
SVGGRAPHER_PLUGINS_DEFS,
'filter' =>
SVGGRAPHER_PLUGINS_FILTER,
'marker' =>
SVGGRAPHER_PLUGINS_MARKER,
'script' =>
SVGGRAPHER_PLUGINS_SCRIPT,
'visual' =>
SVGGRAPHER_PLUGINS_VISUAL);
* Array of plugins names already include for each plugins types.
// PluginManager::incl() {{{
* try to include a plugin file, return true if success or if the plugin is
* already been included. Throw an exception if the plugin is not found.
* @param string $type plugin type
* @param string $name plugin name
public static function incl($type, $name)
if(isset
(self::$incl[$type]) &&
in_array($name, self::$incl[$type])) {
$pluginPath =
self::$pluginsPaths[$type];
$pluginName =
'svgGrapher.' .
$type .
'.' .
$name;
$pluginFile =
$pluginName .
'.php';
if(!file_exists($pluginPath .
'/' .
$pluginFile)) {
throw
new Exception(sprintf('%s plugin (%s) not found.',
include_once $pluginPath .
'/' .
$pluginFile;
self::$incl[$type][] =
$name;
// PluginManager::exist() {{{
* check if a plugin function exist, return the plugin function name if
* exist or throw an exception.
* @param mixed $type plugin type
* @param mixed $name plugin name
public static function exist($type, $name)
self::incl($type, $name);
$pluginFx =
'svgGrapher_' .
$type .
'_' .
$name;
throw
new Exception(sprintf('%s function (%s) not found',
// PluginManager::execute() {{{
* Try to execute a plugin function, and return his result. Throw an
* exception if the plugin file or function can not be found.
* @param string $type plugin type
* @param string $name plugin name
* @param mixed $args params to pass at the function
public static function execute($type, $name, $args=
false)
$pluginFx =
self::exist($type, $name);
throw
new Exception($e->getMessage());
Documentation generated on Tue, 23 Oct 2007 11:32:05 +0200 by phpDocumentor 1.4.0