ZenMagick 0.9.8


org.zenmagick.core.services.plugins.ZMPlugins
\core\services\plugins\ZMPlugins.php at line 47

Class ZMPlugins

ZMObject
└─ZMPlugins

public class ZMPlugins
extends ZMObject

Basic plugin service.

Plugins are grouped via the filesystem. The plugin base directory is expected to contain a subfolder for each group with the folder name being used as group name.

Plugins may consist of either:

a single file
In this case the filename is expected to reflect the classname and the class, in turn, to extend from ZMPlugin.
a directory containing multiple files
In this case the convention require a .php with the same name as the directory in the directory, containing the main plugin class. Again, the classname is expected to be the same as the filename (without the .php extension). It is the plugins responsibility to set use the appropricate loader policy

Author:
DerManoMann
Version:
$Id: ZMPlugins.php 2757 2009-12-18 01:05:38Z dermanomann $

Field Summary
protected mixed

$pluginBaseDir_

protected mixed

$pluginStatus_

protected mixed

$plugins_

Fields inherited from org.zenmagick.core.ZMObject
properties_
Constructor Summary

ZMPlugins()

Create new instance.

Method Summary
protected integer

comparePlugins(ZMPlugin a, ZMPlugin b)

Compare plugins.

array

getAllPlugins(int context, boolean enabled)

Get all plugins.

array

getGroups()

Get a list of available plugin groups.

ZMPlugin

getPluginForId(string id, string group)

Get the plugin for the given id.

protected array

getPluginIdsForGroup(string group)

Generate a full list of plugin ids for the given group.

array

getPluginsForGroup(string group, int context, boolean enabled)

Get all plugins for the given group.

ZMPlugin

initPluginForId(string id, boolean enabled)

Convenience method to init a single plugin.

array

initPluginsForGroups(mixed groups, int context, boolean enabled)

Init all plugins for the given group(s).

array

initPluginsForId(mixed ids, boolean enabled)

Init all plugins of the given type and scope.

static void

instance()

Get instance.

protected array

loadStatus()

Load the plugin status data.

protected boolean

needsInit(string id)

Check if a plugin needs be initialized.

Methods inherited from org.zenmagick.core.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Field Detail

\core\services\plugins\ZMPlugins.php at line 53

pluginBaseDir_

protected mixed $pluginBaseDir_

\core\services\plugins\ZMPlugins.php at line 51

pluginStatus_

protected mixed $pluginStatus_

\core\services\plugins\ZMPlugins.php at line 49

plugins_

protected mixed $plugins_

Constructor Detail

\core\services\plugins\ZMPlugins.php at line 59

ZMPlugins

public ZMPlugins()

Create new instance.


Method Detail

\core\services\plugins\ZMPlugins.php at line 215

comparePlugins

protected integer comparePlugins(ZMPlugin a, ZMPlugin b)

Compare plugins.

Parameters:
a - First plugin.
b - Second plugin.
Returns:
Value less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.

\core\services\plugins\ZMPlugins.php at line 126

getAllPlugins

public array getAllPlugins(int context, boolean enabled)

Get all plugins.

Parameters:
context - Optional context flag; default is 0 for all.
enabled - If true, return only enabled plugins: default is true.
Returns:
A map containing separate lists of ZMPlugin instances for each group.

\core\services\plugins\ZMPlugins.php at line 100

getGroups

public array getGroups()

Get a list of available plugin groups.

Returns:
A list of groups and their associated directories.

\core\services\plugins\ZMPlugins.php at line 231

getPluginForId

public ZMPlugin getPluginForId(string id, string group)

Get the plugin for the given id.

Parameters:
id - The plugin id.
group - Optional group; default is null to auto detect.
Returns:
A plugin instance or null.

\core\services\plugins\ZMPlugins.php at line 141

getPluginIdsForGroup

protected array getPluginIdsForGroup(string group)

Generate a full list of plugin ids for the given group.

Parameters:
group - The plugin group.
Returns:
List of plugin ids.

\core\services\plugins\ZMPlugins.php at line 166

getPluginsForGroup

public array getPluginsForGroup(string group, int context, boolean enabled)

Get all plugins for the given group.

Parameters:
group - The plugin group.
context - Optional context flag; default is 0 for all.
enabled - If true, return only enabled plugins: default is true.
Returns:
A list of ZMPlugin instances.

\core\services\plugins\ZMPlugins.php at line 327

initPluginForId

public ZMPlugin initPluginForId(string id, boolean enabled)

Convenience method to init a single plugin.

Parameters:
id - Either a single id or an id list.
enabled - If true, return only enabled plugins: default is true.
Returns:
A plugin or null.

\core\services\plugins\ZMPlugins.php at line 295

initPluginsForGroups

public array initPluginsForGroups(mixed groups, int context, boolean enabled)

Init all plugins for the given group(s).

Parameters:
groups - Either a single group or a group list.
context - Optional context flag; default is 0 for all.
enabled - If true, return only enabled plugins: default is true.
Returns:
List of initialized plugins.

\core\services\plugins\ZMPlugins.php at line 346

initPluginsForId

public array initPluginsForId(mixed ids, boolean enabled)

Init all plugins of the given type and scope.

NOTE: This method does not check for enabled or similar. It is the responsibility of the calling code to make sure that all ids are actually wanted!

Parameters:
ids - Either a single id or an id list.
enabled - If true, return only enabled plugins: default is true.
Returns:
List of initialized plugins.

\core\services\plugins\ZMPlugins.php at line 79

instance

public static void instance()

Get instance.


\core\services\plugins\ZMPlugins.php at line 91

loadStatus

protected array loadStatus()

Load the plugin status data.

The default implementation is to look at settings in the form zenmagick.core.plugins.[id].enabled.

Returns:
The status of all plugins.

\core\services\plugins\ZMPlugins.php at line 316

needsInit

protected boolean needsInit(string id)

Check if a plugin needs be initialized.

Parameters:
id - The plugin id.
Returns:
true if the plugin needs to be initialized.

ZenMagick 0.9.8