API_VERSION
API_VERSION
API version used by this plugin
Pico dummy plugin - a template for plugins
You're a plugin developer? This template may be helpful :-) Simply remove the events you don't need and add your own logic.
$enabled : boolean|null
This plugin is disabled by default
Usually you should remove this class property (or set it to NULL) to leave the decision whether this plugin should be enabled or disabled by default up to Pico. If all the plugin's dependenies are fulfilled (see \self::$dependsOn), Pico enables the plugin by default. Otherwise the plugin is silently disabled.
If this plugin should never be disabled silently (e.g. when dealing with security-relevant stuff like access control, or similar), set this to TRUE. If Pico can't fulfill all the plugin's dependencies, it will throw an RuntimeException.
If this plugin rather does some "crazy stuff" a user should really be aware of before using it, you can set this to FALSE. The user will then have to enable the plugin manually. However, if another plugin depends on this plugin, it might get enabled silently nevertheless.
No matter what, the user can always explicitly enable or disable this plugin in Pico's config.
$pico : \Pico
Current instance of Pico
__construct(\Pico $pico)
Constructs a new instance of a Pico plugin
\Pico | $pico | current instance of Pico |
setEnabled(boolean $enabled, boolean $recursive = true, boolean $auto = false) : void
Enables or disables this plugin
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() : 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.
plugin is enabled (TRUE) or disabled (FALSE)
getPico() : \Pico
Returns the plugins instance of Pico
the plugins instance of Pico
getPluginConfig(string $configName = null, mixed $default = null) : mixed
Returns either the value of the specified plugin config variable or the config array
string | $configName | optional name of a config variable |
mixed | $default | optional default value to return when the named config variable doesn't exist |
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
onPluginsLoaded(array<mixed,object> $plugins) : void
Triggered after Pico has loaded all available plugins
This event is triggered nevertheless the plugin is enabled or not. It is NOT guaranteed that plugin dependencies are fulfilled!
array<mixed,object> | $plugins | loaded plugin instances |
onSinglePageLoading(string $id, boolean|null $skipPage) : void
Triggered before Pico loads a single page
Set the $skipFile
parameter to TRUE to remove this page from the pages
array. Pico usually passes NULL by default, unless it is a conflicting
page (i.e. content/sub.md
, but there's also a content/sub/index.md
),
then it passes TRUE. Don't change this value incautiously if it isn't
NULL! Someone likely set it to TRUE or FALSE on purpose...
string | $id | relative path to the content file |
boolean|null | $skipPage | set this to TRUE to remove this page from the pages array, otherwise leave it unchanged |
onSinglePageContent(string $id, $rawContent) : void
Triggered when Pico loads the raw contents of a single page
Please note that this event isn't triggered when the currently processed page is the requested page. The reason for this exception is that the raw contents of this page were loaded already.
string | $id | relative path to the content file |
$rawContent |
onSinglePageLoaded(array $pageData) : void
Triggered when Pico loads a single page
Please refer to \Pico::readPages() for information about the structure of a single page's data.
array | $pageData |
onPagesDiscovered(array $pages) : void
Triggered after Pico has discovered all known pages
Pico's pages array isn't sorted until the onPagesLoaded
event is
triggered. Please refer to \Pico::readPages() for information
about the structure of Pico's pages array and the structure of a single
page's data.
array | $pages |
onPagesLoaded(array $pages) : void
Triggered after Pico has sorted the pages array
Please refer to \Pico::readPages() for information about the structure of Pico's pages array and the structure of a single page's data.
array | $pages |
onCurrentPageDiscovered(array $currentPage = null, array $previousPage = null, array $nextPage = null) : void
Triggered when Pico discovered the current, previous and next pages
If Pico isn't serving a regular page, but a plugin's virtual page, there will neither be a current, nor previous or next pages. Please refer to \Pico::readPages() for information about the structure of a single page's data.
array | $currentPage | |
array | $previousPage | |
array | $nextPage |
onPageTreeBuilt(array $pageTree) : void
Triggered after Pico built the page tree
Please refer to \Pico::buildPageTree() for information about the structure of Pico's page tree array.
array | $pageTree |
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.
thrown when the plugin's and Pico's API aren't compatible