rcube_plugin_api

The plugin loader and global API

package

Framework

subpackage

PluginAPI

Methods

This implements the 'singleton' design pattern

get_instance() : \rcube_plugin_api
static

Response

\rcube_plugin_api

The one and only instance if this class

Private constructor

__construct() 

Initialize plugin engine

init($app, $task = '') 

This has to be done after rcmail::load_gui() or rcmail::json_init() was called because plugins need to have access to rcmail->output

Arguments

$app

$task

Load and init all enabled plugins

load_plugins($plugins_enabled, $required_plugins = array()) 

This has to be done after rcmail::load_gui() or rcmail::json_init() was called because plugins need to have access to rcmail->output

Arguments

$plugins_enabled

$required_plugins

Load the specified plugin

load_plugin($plugin_name, $force = false) : boolean

Arguments

$plugin_name

$force

Response

boolean

True on success, false if not loaded or failure

Get information about a specific plugin.

get_info($plugin_name) : array

This is either provided my a plugin's info() method or extracted from a package.xml or a composer.json file

Arguments

$plugin_name

Response

array

Meta information about a plugin or False if plugin was not found

Allows a plugin object to register a callback for a certain hook

register_hook(string $hook, mixed $callback) 

Arguments

$hook

string

Hook name

$callback

mixed

String with global function name or array($obj, 'methodname')

Allow a plugin object to unregister a callback.

unregister_hook(string $hook, mixed $callback) 

Arguments

$hook

string

Hook name

$callback

mixed

String with global function name or array($obj, 'methodname')

Triggers a plugin hook.

exec_hook(string $hook, array $args = array()) : array

This is called from the application and executes all registered handlers

Arguments

$hook

string

Hook name

$args

array

Named arguments (key->value pairs)

Response

array

The (probably) altered hook arguments

Let a plugin register a handler for a specific request

register_action(string $action, string $owner, mixed $callback, string $task = null) 

Arguments

$action

string

Action name (_task=mail&_action=plugin.foo)

$owner

string

Plugin name that registers this action

$callback

mixed

Callback: string with global function name or array($obj, 'methodname')

$task

string

Task name registered by this plugin

This method handles requests like _task=mail&_action=plugin.foo It executes the callback function that was registered with the given action.

exec_action(string $action) 

Arguments

$action

string

Action name

Register a handler function for template objects

register_handler(string $name, string $owner, mixed $callback) 

Arguments

$name

string

Object name

$owner

string

Plugin name that registers this action

$callback

mixed

Callback: string with global function name or array($obj, 'methodname')

Register this plugin to be responsible for a specific task

register_task(string $task, string $owner) 

Arguments

$task

string

Task name (only characters [a-z0-9_-] are allowed)

$owner

string

Plugin name that registers this action

Checks whether the given task is registered by a plugin

is_plugin_task(string $task) : boolean

Arguments

$task

string

Task name

Response

boolean

True if registered, otherwise false

Check if a plugin hook is currently processing.

is_processing(string $hook = null) : boolean

Mainly used to prevent loops and recursion.

Arguments

$hook

string

Hook to check (optional)

Response

boolean

True if any/the given hook is currently processed, otherwise false

Include a plugin script file in the current HTML page

include_script(string $fn) 

Arguments

$fn

string

Path to script

Include a plugin stylesheet in the current HTML page

include_stylesheet(string $fn) 

Arguments

$fn

string

Path to stylesheet

Save the given HTML content to be added to a template container

add_content(string $html, string $container) 

Arguments

$html

string

HTML content

$container

string

Template container identifier

Returns list of loaded plugins names

loaded_plugins() : array

Response

array

List of plugin names

Callback for template_container hooks

template_container_hook(array $attrib) : array

Arguments

$attrib

array

Response

array

Make the given file name link into the plugins directory

resource_url(string $fn) : string

Arguments

$fn

string

Filename

Response

string

Properties

instance

instance : 
static

dir

dir : 

url

url : 

task

task : 

output

output : 

handlers

handlers : 

allowed_prefs

allowed_prefs : 

allowed_session_prefs

allowed_session_prefs : 

plugins

plugins : 

tasks

tasks : 

actions

actions : 

actionmap

actionmap : 

objectsmap

objectsmap : 

template_contents

template_contents : 

active_hook

active_hook : 

deprecated_hooks

deprecated_hooks :