ZenMagick 0.9.10


zenmagick.store.shared.services.plugins\Plugin
services\plugins\Plugin.php at line 34

Class Plugin

ZMObject
└─ZMPlugin
└─Plugin

public class Plugin
extends ZMPlugin

Store plugin base class.

Plugins are NOT compatible with zen-cart modules.

The plugin code (id) is based on the plugin class/file name.

Author:
DerManoMann

Constant Summary
final static int

CONTEXT_ADMIN

Admin context.

final static int

CONTEXT_STOREFRONT

Store context.

final static str

KEY_ENABLED

internal key constant

final static str

KEY_PREFIX

internal key constant

final static str

KEY_SORT_ORDER

internal key constant

Method Summary
void

__construct(string title, string description, string version)

Create new plugin.

void

addConfigValue(string title, string key, string value, string description, string widget, int sortOrder)

Add a configuration value.

void

addMenuItem(string id, string title, string function, string menuKey)

Add plugin maintenance screen to navigation.

void

addMenuItem2(string title, mixed requestId, string menuKey, string id, string function)

Add custom plugin admin page to admin navigation.

mixed

get(string name, mixed default)

Here, the $default parameter is always ingnored.

ZMAdminMenu

getAdminMenu()

Get admin menu.

string

getConfigPath(string file)

Get a plugin config file path.

array

getConfigValues()

Get all the config values.

array

getGlobal(ZMRequest request)

Get optional files to be loaded in global scope.

array

getMessages()

Get optional installation messages.

int

getSortOrder()

Get the sort order.

boolean

hasOptions()

Check if this plugin has options configurable via the default plugin options dialog.

void

init()

Init this plugin.

void

install()

Install this plugin.

boolean

isEnabled()

Check if the plugin is enabled.

boolean

isInstalled()

Check if the plugin is installed.

string

pluginURL(string uri)

Resolve a plugin relative URI.

void

remove(boolean keepSettings)

Remove this plugin.

void

set(string name, mixed value)

Support to set plugin config values by name.

void

setEnabled(boolean status)

Set the status.

void

setGroup(string group)

{@inheritDoc}

void

setPreferredSortOrder(int sortOrder)

Set the preferred sort order.

void

setSortOrder(int sortOrder)

Set the sort order.

boolean

upgrade()

Upgrade this plugin.

Methods inherited from org.zenmagick.core.services.plugins\ZMPlugin
__construct, getContext, getDescription, getGroup, getId, getLoaderPolicy, getName, getPluginDirectory, getVersion, init, isEnabled, setContext, setDescription, setEnabled, setGroup, setId, setLoaderPolicy, setName, setPluginDirectory, setVersion
Methods inherited from org.zenmagick.core\ZMObject
__construct, attachMethod, get, getAttachedMethods, getProperties, getPropertyNames, set, singleton

Constant Detail

services\plugins\Plugin.php at line 45

CONTEXT_ADMIN

public final static int CONTEXT_ADMIN = 2

Admin context.


services\plugins\Plugin.php at line 43

CONTEXT_STOREFRONT

public final static int CONTEXT_STOREFRONT = 1

Store context.


services\plugins\Plugin.php at line 38

KEY_ENABLED

public final static str KEY_ENABLED = 'ENABLED'

internal key constant


services\plugins\Plugin.php at line 36

KEY_PREFIX

public final static str KEY_PREFIX = 'PLUGIN_'

internal key constant


services\plugins\Plugin.php at line 40

KEY_SORT_ORDER

public final static str KEY_SORT_ORDER = 'SORT_ORDER'

internal key constant


Method Detail

services\plugins\Plugin.php at line 61

__construct

public void __construct(string title, string description, string version)

Create new plugin.

Parameters:
title - The title.
description - The description.
version - The version.

services\plugins\Plugin.php at line 304

addConfigValue

public void addConfigValue(string title, string key, string value, string description, string widget, int sortOrder)

Add a configuration value.

If no sort order is specified, entries will be listed in the order they are added. Effectively, this means sort order can be easier accomplished by adding values in the order they should be displayed.

Parameters:
title - The title.
key - The configuration key (with or without the common prefix).
value - The value.
description - The description; defaults to ''.
widget - The widget definitio; default is null for a default text field.
sortOrder - The sort order; defaults to 0.

services\plugins\Plugin.php at line 352

addMenuItem

public void addMenuItem(string id, string title, string function, string menuKey)

Add plugin maintenance screen to navigation.

The provided function is free to implement content generation in one of two different ways:

  1. BASIC:
    The page contents is generated as-is. No output buffering or similar. Expected return value is null.
  2. ADVANCED:
    Content is not generated directly, but included as part of the returned ZMPluginPage instance.

Parameters:
id - The page id.
title - The page title.
function - The function to render the contents.
menuKey - Optional key determining where the menu item should appear; default is ZMAdminMenu::MENU_PLUGINS.

services\plugins\Plugin.php at line 369

addMenuItem2

public void addMenuItem2(string title, mixed requestId, string menuKey, string id, string function)

Add custom plugin admin page to admin navigation.

Plugins are expected to implement a corresponding controller for the configured reuqestId.

Parameters:
id - The page id.
title - The page title.
function - The function to render the contents.
menuKey - Optional key determining where the menu item should appear; default is ZMAdminMenu::MENU_PLUGINS.
Todo::
fix and allow optional other parameter, etc...

services\plugins\Plugin.php at line 125

get

public mixed get(string name, mixed default)

Here, the $default parameter is always ingnored.

Parameters:
name - The property name.
default - A default value; default value is null.
Returns:
The value or null.

services\plugins\Plugin.php at line 408

getAdminMenu

public ZMAdminMenu getAdminMenu()

Get admin menu.

Returns:
An admin menu instance or null if not available.

services\plugins\Plugin.php at line 279

getConfigPath

public string getConfigPath(string file)

Get a plugin config file path.

Return a fully qualified filename; resolved either against the plugin directory or config/. If neither file exists, the config/ based filename is returned.

Parameters:
file - The filename.
Returns:
A fully qualified filename.

services\plugins\Plugin.php at line 329

getConfigValues

public array getConfigValues()

Get all the config values.

Returns:
A list of ZMConfigValue instances.

services\plugins\Plugin.php at line 100

getGlobal

public array getGlobal(ZMRequest request)

Get optional files to be loaded in global scope.

Files returned here would typically have an extension different to .php as otherwise the loader will load them as static.

Parameters:
request - The current request.
Returns:
List of filenames relative to the plugin location.

services\plugins\Plugin.php at line 87

getMessages

public array getMessages()

Get optional installation messages.

Returns:
List of ZMMessage instances.

services\plugins\Plugin.php at line 251

getSortOrder

public int getSortOrder()

Get the sort order.

Returns:
The sort order index.

services\plugins\Plugin.php at line 399

hasOptions

public boolean hasOptions()

Check if this plugin has options configurable via the default plugin options dialog.

Returns:
true if options are available.

services\plugins\Plugin.php at line 215

init

public void init()

Init this plugin.

This method is part of the lifecylce of a plugin during storefront request handling.

Code to set up internal resources should be placed here, rather than in the * constructor.


services\plugins\Plugin.php at line 174

install

public void install()

Install this plugin.

This default implementation will automatically create the following settings:


services\plugins\Plugin.php at line 232

isEnabled

public boolean isEnabled()

Check if the plugin is enabled.

Returns:
true if the plugin is enabled, false if not.

services\plugins\Plugin.php at line 223

isInstalled

public boolean isInstalled()

Check if the plugin is installed.

Returns:
true if the plugin is installed, false if not.

services\plugins\Plugin.php at line 385

pluginURL

public string pluginURL(string uri)

Resolve a plugin relative URI.

The given uri is assumed to be relative to the plugin folder.

Parameters:
uri - The relative URI.
Returns:
An absolute URL or null.

services\plugins\Plugin.php at line 186

remove

public void remove(boolean keepSettings)

Remove this plugin.

Parameters:
keepSettings - If set to true, the settings will not be removed; default is false.

services\plugins\Plugin.php at line 152

set

public void set(string name, mixed value)

Support to set plugin config values by name.

Parameters:
name - The property name.
value - The value.

services\plugins\Plugin.php at line 242

setEnabled

public void setEnabled(boolean status)

Set the status.

Parameters:
status - The new status.

services\plugins\Plugin.php at line 263

setGroup

public void setGroup(string group)

Set the group.

Parameters:
group - The group.

services\plugins\Plugin.php at line 161

setPreferredSortOrder

public void setPreferredSortOrder(int sortOrder)

Set the preferred sort order.

Parameters:
sortOrder - The preferred sort order.

services\plugins\Plugin.php at line 258

setSortOrder

public void setSortOrder(int sortOrder)

Set the sort order.

Parameters:
sortOrder - The sort order index.

services\plugins\Plugin.php at line 203

upgrade

public boolean upgrade()

Upgrade this plugin.

Returns:
true on success.

ZenMagick 0.9.10