DummyPlugin
extends AbstractPicoPlugin
in package
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.
Tags
Table of Contents
Constants
- API_VERSION = 4
- API version used by this plugin
Methods
- __call() : mixed
- Passes all not satisfiable method calls to Pico
- __construct() : mixed
- Constructs a new instance of a Pico plugin
- getDependants() : array<string|int, object>
- Returns a list of plugins which depend on this plugin
- getDependencies() : array<string|int, string>
- Returns a list of names of plugins required by this plugin
- getPico() : Pico
- Returns the plugin's instance of Pico
- getPluginConfig() : mixed
- Returns either the value of the specified plugin config variable or the config array
- handleEvent() : mixed
- Handles a event that was triggered by Pico
- isEnabled() : bool|null
- Returns a boolean indicating whether this plugin is enabled or not
- isStatusChanged() : bool
- Returns TRUE if the plugin was ever enabled/disabled manually
- on404ContentLoaded() : void
- Triggered after Pico has read the contents of the 404 file
- on404ContentLoading() : void
- Triggered before Pico reads the contents of a 404 file
- onConfigLoaded() : void
- Triggered after Pico has read its configuration
- onContentLoaded() : void
- Triggered after Pico has read the contents of the file to serve
- onContentLoading() : void
- Triggered before Pico reads the contents of the file to serve
- onContentParsed() : void
- Triggered after Pico has parsed the contents of the file to serve
- onContentParsing() : void
- Triggered before Pico parses the pages content
- onContentPrepared() : void
- Triggered after Pico has prepared the raw file contents for parsing
- onCurrentPageDiscovered() : void
- Triggered when Pico discovered the current, previous and next pages
- onMetaHeaders() : void
- Triggered when Pico reads its known meta header fields
- onMetaParsed() : void
- Triggered after Pico has parsed the meta header
- onMetaParsing() : void
- Triggered before Pico parses the meta header
- onPageRendered() : void
- Triggered after Pico has rendered the page
- onPageRendering() : void
- Triggered before Pico renders the page
- onPagesDiscovered() : void
- Triggered after Pico has discovered all known pages
- onPagesLoaded() : void
- Triggered after Pico has sorted the pages array
- onPagesLoading() : void
- Triggered before Pico reads all known pages
- onPageTreeBuilt() : void
- Triggered after Pico built the page tree
- onParsedownRegistered() : void
- Triggered when Pico registers the Parsedown parser
- onPluginManuallyLoaded() : void
- Triggered when Pico manually loads a plugin
- onPluginsLoaded() : void
- Triggered after Pico has loaded all available plugins
- onRequestFile() : void
- Triggered after Pico has discovered the content file to serve
- onRequestUrl() : void
- Triggered after Pico has evaluated the request URL
- onSinglePageContent() : void
- Triggered when Pico loads the raw contents of a single page
- onSinglePageLoaded() : void
- Triggered when Pico loads a single page
- onSinglePageLoading() : void
- Triggered before Pico loads a single page
- onThemeLoaded() : void
- Triggered after Pico loaded its theme
- onThemeLoading() : void
- Triggered before Pico loads its theme
- onTwigRegistered() : void
- Triggered when Pico registers the twig template engine
- onYamlParserRegistered() : void
- Triggered when Pico registers the YAML parser
- setEnabled() : mixed
- Enables or disables this plugin
Constants
API_VERSION
API version used by this plugin
public
int
API_VERSION
= 4
Methods
__call()
Passes all not satisfiable method calls to Pico
public
__call(string $methodName, array<string|int, mixed> $params) : mixed
Parameters
- $methodName : string
-
name of the method to call
- $params : array<string|int, mixed>
-
parameters to pass
Tags
Return values
mixed —return value of the called method
__construct()
Constructs a new instance of a Pico plugin
public
__construct(Pico $pico) : mixed
Parameters
- $pico : Pico
-
current instance of Pico
getDependants()
Returns a list of plugins which depend on this plugin
public
getDependants() : array<string|int, object>
Return values
array<string|int, object> —dependant plugins
getDependencies()
Returns a list of names of plugins required by this plugin
public
getDependencies() : array<string|int, string>
Return values
array<string|int, string> —required plugins
getPico()
Returns the plugin's instance of Pico
public
getPico() : Pico
Return values
Pico —the plugin's instance of Pico
getPluginConfig()
Returns either the value of the specified plugin config variable or the config array
public
getPluginConfig([string $configName = null ][, mixed $default = null ]) : mixed
Parameters
- $configName : string = null
-
optional name of a config variable
- $default : mixed = null
-
optional default value to return when the named config variable doesn't exist
Return values
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
handleEvent()
Handles a event that was triggered by Pico
public
handleEvent(mixed $eventName, array<string|int, mixed> $params) : mixed
Parameters
- $eventName : mixed
-
name of the triggered event
- $params : array<string|int, mixed>
-
passed parameters
isEnabled()
Returns a boolean indicating whether this plugin is enabled or not
public
isEnabled() : bool|null
Return values
bool|null —plugin is enabled (TRUE) or disabled (FALSE)
isStatusChanged()
Returns TRUE if the plugin was ever enabled/disabled manually
public
isStatusChanged() : bool
Return values
bool —plugin is in its default state (TRUE), FALSE otherwise
on404ContentLoaded()
Triggered after Pico has read the contents of the 404 file
public
on404ContentLoaded(string &$rawContent) : void
Parameters
- $rawContent : string
-
raw file contents
Tags
on404ContentLoading()
Triggered before Pico reads the contents of a 404 file
public
on404ContentLoading() : void
Tags
onConfigLoaded()
Triggered after Pico has read its configuration
public
onConfigLoaded(array<string|int, mixed> &$config) : void
Parameters
- $config : array<string|int, mixed>
-
array of config variables
Tags
onContentLoaded()
Triggered after Pico has read the contents of the file to serve
public
onContentLoaded(string &$rawContent) : void
If Pico serves a 404 file, this event is triggered with the raw contents of said 404 file. Use Pico::is404Content() to check for this case when necessary.
Parameters
- $rawContent : string
-
raw file contents
Tags
onContentLoading()
Triggered before Pico reads the contents of the file to serve
public
onContentLoading() : void
Tags
onContentParsed()
Triggered after Pico has parsed the contents of the file to serve
public
onContentParsed(string &$content) : void
Parameters
- $content : string
-
parsed contents (HTML) of the requested page
Tags
onContentParsing()
Triggered before Pico parses the pages content
public
onContentParsing() : void
Tags
onContentPrepared()
Triggered after Pico has prepared the raw file contents for parsing
public
onContentPrepared(string &$markdown) : void
Parameters
- $markdown : string
-
Markdown contents of the requested page
Tags
onCurrentPageDiscovered()
Triggered when Pico discovered the current, previous and next pages
public
onCurrentPageDiscovered([array<string|int, mixed>|null &$currentPage = null ][, array<string|int, mixed>|null &$previousPage = null ][, array<string|int, mixed>|null &$nextPage = null ]) : void
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.
Parameters
- $currentPage : array<string|int, mixed>|null = null
-
data of the page being served
- $previousPage : array<string|int, mixed>|null = null
-
data of the previous page
- $nextPage : array<string|int, mixed>|null = null
-
data of the next page
Tags
onMetaHeaders()
Triggered when Pico reads its known meta header fields
public
onMetaHeaders(array<string|int, string> &$headers) : void
Parameters
- $headers : array<string|int, string>
-
list of known meta header fields; the array key specifies the YAML key to search for, the array value is later used to access the found value
Tags
onMetaParsed()
Triggered after Pico has parsed the meta header
public
onMetaParsed(array<string|int, string> &$meta) : void
Parameters
- $meta : array<string|int, string>
-
parsed meta data
Tags
onMetaParsing()
Triggered before Pico parses the meta header
public
onMetaParsing() : void
Tags
onPageRendered()
Triggered after Pico has rendered the page
public
onPageRendered(string &$output) : void
Parameters
- $output : string
-
contents which will be sent to the user
Tags
onPageRendering()
Triggered before Pico renders the page
public
onPageRendering(string &$templateName, array<string|int, mixed> &$twigVariables) : void
Parameters
- $templateName : string
-
file name of the template
- $twigVariables : array<string|int, mixed>
-
template variables
Tags
onPagesDiscovered()
Triggered after Pico has discovered all known pages
public
onPagesDiscovered(array<string|int, array<string|int, mixed>> &$pages) : void
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.
Parameters
- $pages : array<string|int, array<string|int, mixed>>
-
list of all known pages
Tags
onPagesLoaded()
Triggered after Pico has sorted the pages array
public
onPagesLoaded(array<string|int, array<string|int, mixed>> &$pages) : void
Please refer to Pico::readPages() for information about the structure of Pico's pages array and the structure of a single page's data.
Parameters
- $pages : array<string|int, array<string|int, mixed>>
-
sorted list of all known pages
Tags
onPagesLoading()
Triggered before Pico reads all known pages
public
onPagesLoading() : void
Tags
onPageTreeBuilt()
Triggered after Pico built the page tree
public
onPageTreeBuilt(array<string|int, mixed> &$pageTree) : void
Please refer to Pico::buildPageTree() for information about the structure of Pico's page tree array.
Parameters
- $pageTree : array<string|int, mixed>
-
page tree
Tags
onParsedownRegistered()
Triggered when Pico registers the Parsedown parser
public
onParsedownRegistered(Parsedown &$parsedown) : void
Parameters
- $parsedown : Parsedown
-
Parsedown instance
Tags
onPluginManuallyLoaded()
Triggered when Pico manually loads a plugin
public
onPluginManuallyLoaded(object $plugin) : void
Parameters
- $plugin : object
-
loaded plugin instance
Tags
onPluginsLoaded()
Triggered after Pico has loaded all available plugins
public
onPluginsLoaded(array<string|int, object> $plugins) : void
This event is triggered nevertheless the plugin is enabled or not. It is NOT guaranteed that plugin dependencies are fulfilled!
Parameters
- $plugins : array<string|int, object>
-
loaded plugin instances
Tags
onRequestFile()
Triggered after Pico has discovered the content file to serve
public
onRequestFile(string &$file) : void
Parameters
- $file : string
-
absolute path to the content file to serve
Tags
onRequestUrl()
Triggered after Pico has evaluated the request URL
public
onRequestUrl(string &$url) : void
Parameters
- $url : string
-
part of the URL describing the requested contents
Tags
onSinglePageContent()
Triggered when Pico loads the raw contents of a single page
public
onSinglePageContent(string $id, string &$rawContent) : void
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.
Parameters
- $id : string
-
relative path to the content file
- $rawContent : string
-
raw file contents
Tags
onSinglePageLoaded()
Triggered when Pico loads a single page
public
onSinglePageLoaded(array<string|int, mixed> &$pageData) : void
Please refer to Pico::readPages() for information about the structure of a single page's data.
Parameters
- $pageData : array<string|int, mixed>
-
data of the loaded page
Tags
onSinglePageLoading()
Triggered before Pico loads a single page
public
onSinglePageLoading(string $id, bool|null &$skipPage) : void
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...
Parameters
- $id : string
-
relative path to the content file
- $skipPage : bool|null
-
set this to TRUE to remove this page from the pages array, otherwise leave it unchanged
Tags
onThemeLoaded()
Triggered after Pico loaded its theme
public
onThemeLoaded(string $theme, int $themeApiVersion, array<string|int, mixed> &$themeConfig) : void
Parameters
- $theme : string
-
name of current theme
- $themeApiVersion : int
-
API version of the theme
- $themeConfig : array<string|int, mixed>
-
config array of the theme
Tags
onThemeLoading()
Triggered before Pico loads its theme
public
onThemeLoading(string &$theme) : void
Parameters
- $theme : string
-
name of current theme
Tags
onTwigRegistered()
Triggered when Pico registers the twig template engine
public
onTwigRegistered(TwigEnvironment &$twig) : void
Parameters
- $twig : TwigEnvironment
-
Twig instance
Tags
onYamlParserRegistered()
Triggered when Pico registers the YAML parser
public
onYamlParserRegistered(YamlParser &$yamlParser) : void
Parameters
- $yamlParser : YamlParser
-
YAML parser instance
Tags
setEnabled()
Enables or disables this plugin
public
setEnabled(mixed $enabled[, mixed $recursive = true ][, mixed $auto = false ]) : mixed
Parameters
- $enabled : mixed
-
enable (TRUE) or disable (FALSE) this plugin
- $recursive : mixed = true
-
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.
- $auto : mixed = false
-
enable or disable to fulfill a dependency. This parameter is optional and defaults to FALSE.