ZenMagick 0.9.10


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

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

Field Summary
protected mixed

$pluginBaseDir_

protected mixed

$pluginStatus_

protected mixed

$plugins_

Fields inherited from org.zenmagick.core\ZMObject
properties_
Method Summary
void

__construct()

Create new instance.

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
__construct, attachMethod, get, getAttachedMethods, getProperties, getPropertyNames, set, singleton

Field Detail

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

pluginBaseDir_

protected mixed $pluginBaseDir_

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

pluginStatus_

protected mixed $pluginStatus_

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

plugins_

protected mixed $plugins_

Method Detail

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

__construct

public void __construct()

Create new instance.


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

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 125

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 99

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 230

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 140

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 165

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 326

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 294

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 345

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 78

instance

public static void instance()

Get instance.


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

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 315

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.10