\AbstractPicoPlugin

Abstract class to extend from when implementing a Pico plugin

Please refer to \PicoPluginInterface for more information about how to develop a plugin for Pico.

Summary

Methods
Properties
Constants
__construct()
handleEvent()
setEnabled()
isEnabled()
isStatusChanged()
getPico()
getPluginConfig()
__call()
getDependencies()
getDependants()
No public properties found
No constants found
checkDependencies()
checkDependants()
checkCompatibility()
$enabled
$statusChanged
$nativePlugin
$dependsOn
N/A
No private methods found
$pico
$dependants
N/A

Properties

$enabled

$enabled : boolean|null

Boolean indicating if this plugin is enabled (TRUE) or disabled (FALSE)

Type

boolean|null

$statusChanged

$statusChanged : boolean

Boolean indicating if this plugin was ever enabled/disabled manually

Type

boolean

$nativePlugin

$nativePlugin : boolean|null

Boolean indicating whether this plugin matches Pico's API version

Type

boolean|null

$dependsOn

$dependsOn : array<mixed,string>

List of plugins which this plugin depends on

Type

array<mixed,string>

$pico

$pico : \Pico

Current instance of Pico

Type

\Pico

$dependants

$dependants : array<mixed,object>|null

List of plugin which depend on this plugin

Type

array<mixed,object>|null

Methods

__construct()

__construct(\Pico  $pico) 

Constructs a new instance of a Pico plugin

Parameters

\Pico $pico

current instance of Pico

handleEvent()

handleEvent(string  $eventName, array  $params) : void

Handles a event that was triggered by Pico

Parameters

string $eventName

name of the triggered event

array $params

passed parameters

setEnabled()

setEnabled(boolean  $enabled, boolean  $recursive = true, boolean  $auto = false) : void

Enables or disables this plugin

Parameters

boolean $enabled

enable (TRUE) or disable (FALSE) this plugin

boolean $recursive

when TRUE, enable or disable recursively. In other words, if you enable a plugin, all required plugins are enabled, too. When disabling a plugin, all depending plugins are disabled likewise. Recursive operations are only performed as long as a plugin wasn't enabled/disabled manually. This parameter is optional and defaults to TRUE.

boolean $auto

enable or disable to fulfill a dependency. This parameter is optional and defaults to FALSE.

isEnabled()

isEnabled() : boolean|null

Returns a boolean indicating whether this plugin is enabled or not

You musn't rely on the return value when Pico's onConfigLoaded event wasn't triggered on all plugins yet. This method might even return NULL then. The plugin's status might change later.

Returns

boolean|null —

plugin is enabled (TRUE) or disabled (FALSE)

isStatusChanged()

isStatusChanged() : boolean

Returns TRUE if the plugin was ever enabled/disabled manually

Returns

boolean —

plugin is in its default state (TRUE), FALSE otherwise

getPico()

getPico() : \Pico

Returns the plugins instance of Pico

Returns

\Pico

the plugins instance of Pico

getPluginConfig()

getPluginConfig(string  $configName = null, mixed  $default = null) : mixed

Returns either the value of the specified plugin config variable or the config array

Parameters

string $configName

optional name of a config variable

mixed $default

optional default value to return when the named config variable doesn't exist

Returns

mixed —

if no name of a config variable has been supplied, the plugin's config array is returned; otherwise it returns either the value of the named config variable, or, if the named config variable doesn't exist, the provided default value or NULL

__call()

__call(string  $methodName, array  $params) : mixed

Passes all not satisfiable method calls to Pico

Parameters

string $methodName

name of the method to call

array $params

parameters to pass

Returns

mixed —

return value of the called method

getDependencies()

getDependencies() : array<mixed,string>

Returns a list of names of plugins required by this plugin

Returns

array<mixed,string> —

required plugins

getDependants()

getDependants() : array<mixed,object>

Returns a list of plugins which depend on this plugin

Returns

array<mixed,object> —

dependant plugins

checkDependencies()

checkDependencies(boolean  $recursive) : void

Enables all plugins which this plugin depends on

Parameters

boolean $recursive

enable required plugins automatically

Throws

\RuntimeException

thrown when a dependency fails

checkDependants()

checkDependants(boolean  $recursive) : void

Disables all plugins which depend on this plugin

Parameters

boolean $recursive

disabled dependant plugins automatically

Throws

\RuntimeException

thrown when a dependency fails

checkCompatibility()

checkCompatibility() : void

Checks compatibility with Pico's API version

Pico automatically adds a dependency to \PicoDeprecated when the plugin's API is older than Pico's API. \PicoDeprecated furthermore throws a exception when it can't provide compatibility in such cases. However, we still have to decide whether this plugin is compatible to newer API versions, what requires some special (version specific) precaution and is therefore usually not the case.

Throws

\RuntimeException

thrown when the plugin's and Pico's API aren't compatible