PHP Class PicoDeprecated

This plugin exists for backward compatibility and is disabled by default. It gets automatically enabled when a plugin which doesn't implement {@link PicoPluginInterface} is loaded. This plugin triggers deprecated events and automatically enables {@link PicoParsePagesContent} and {@link PicoExcerpt}. These plugins heavily impact Pico's performance! You can disable this plugin by calling {@link PicoDeprecated::setEnabled()}. The following deprecated events are triggered by this plugin: | Event | ... triggers the deprecated event | | ------------------- | --------------------------------------------------------- | | onPluginsLoaded | plugins_loaded() | | onConfigLoaded | config_loaded($config) | | onRequestUrl | request_url($url) | | onContentLoading | before_load_content($file) | | onContentLoaded | after_load_content($file, $rawContent) | | on404ContentLoading | before_404_load_content($file) | | on404ContentLoaded | after_404_load_content($file, $rawContent) | | onMetaHeaders | before_read_file_meta($headers) | | onMetaParsed | file_meta($meta) | | onContentParsing | before_parse_content($rawContent) | | onContentParsed | after_parse_content($content) | | onContentParsed | content_parsed($content) | | onSinglePageLoaded | get_page_data($pages, $meta) | | onPagesLoaded | get_pages($pages, $currentPage, $previousPage, $nextPage) | | onTwigRegistration | before_twig_register() | | onPageRendering | before_render($twigVariables, $twig, $templateName) | | onPageRendered | after_render($output) | Since Pico 1.0 the config is stored in {@path "config/config.php"}. This plugin tries to read {@path "config.php"} in Pico's root dir and overwrites all settings previously specified in {@path "config/config.php"}.
Author: Daniel Rudolf
Inheritance: extends AbstractPicoPlugin
Show file Open project: gilbitron/pico

Protected Properties

Property Type Description
$enabled This plugin is disabled by default
$requestFile string | null The requested file

Public Methods

Method Description
on404ContentLoaded ( &$rawContent ) Triggers the deprecated event after_404_load_content($file, $rawContent)
on404ContentLoading ( &$file ) Triggers the deprecated before_404_load_content($file)
onConfigLoaded ( array &$config ) : void Triggers the deprecated event config_loaded($config)
onContentLoaded ( &$rawContent ) Triggers the deprecated event after_load_content($file, $rawContent)
onContentLoading ( &$file ) Triggers the deprecated before_load_content($file)
onContentParsed ( &$content ) Triggers the deprecated events after_parse_content($content) and content_parsed($content)
onContentParsing ( &$rawContent ) Triggers the deprecated event before_parse_content($rawContent)
onMetaHeaders ( array &$headers ) Triggers the deprecated event before_read_file_meta($headers)
onMetaParsed ( array &$meta ) Triggers the deprecated event file_meta($meta)
onPageRendered ( &$output ) Triggers the deprecated event after_render($output)
onPageRendering ( Twig_Environment &$twig, array &$twigVariables, &$templateName ) Triggers the deprecated event before_render($twigVariables, $twig, $templateName)
onPagesLoaded ( array &$pages, array &$currentPage = null, array &$previousPage = null, array &$nextPage = null ) Triggers the deprecated event get_pages($pages, $currentPage, $previousPage, $nextPage)
onPluginsLoaded ( array &$plugins ) Enables this plugin on demand and triggers the deprecated event plugins_loaded()
onRequestFile ( &$file ) Sets PicoDeprecated::$requestFile to trigger the deprecated events after_load_content() and after_404_load_content()
onRequestUrl ( &$url ) Triggers the deprecated event request_url($url)
onSinglePageLoaded ( array &$pageData ) Triggers the deprecated event get_page_data($pages, $meta)
onTwigRegistration ( ) Triggers the deprecated event before_twig_register()

Protected Methods

Method Description
defineConstants ( ) : void Defines deprecated constants
enablePlugins ( ) : void Enables the plugins PicoParsePagesContent and PicoExcerpt
loadRootDirConfig ( array &$realConfig ) : void Read config.php in Pico's root dir
triggerEvent ( string $eventName, array $params = [] ) : void Triggers a deprecated event on all plugins

Method Details

defineConstants() protected method

ROOT_DIR, LIB_DIR, PLUGINS_DIR, THEMES_DIR and CONTENT_EXT are deprecated since v1.0, CONTENT_DIR existed just in v0.9, CONFIG_DIR just for a short time between v0.9 and v1.0 and CACHE_DIR was dropped with v1.0 without a replacement.
See also: PicoDeprecated::onConfigLoaded()
protected defineConstants ( ) : void
return void

enablePlugins() protected method

Enables the plugins PicoParsePagesContent and PicoExcerpt
See also: PicoParsePagesContent
See also: PicoExcerpt
protected enablePlugins ( ) : void
return void

loadRootDirConfig() protected method

Read config.php in Pico's root dir
See also: PicoDeprecated::onConfigLoaded()
See also: Pico::loadConfig()
protected loadRootDirConfig ( array &$realConfig ) : void
$realConfig array
return void

on404ContentLoaded() public method

Triggers the deprecated event after_404_load_content($file, $rawContent)
See also: DummyPlugin::on404ContentLoaded()
public on404ContentLoaded ( &$rawContent )

on404ContentLoading() public method

Triggers the deprecated before_404_load_content($file)
See also: DummyPlugin::on404ContentLoading()
public on404ContentLoading ( &$file )

onConfigLoaded() public method

This method also defines deprecated constants, reads the config.php in Pico's root dir, enables the plugins {@link PicoParsePagesContent} and {@link PicoExcerpt} and makes $config globally accessible (the latter was removed with Pico 0.9 and was added again as deprecated feature with Pico 1.0)
See also: PicoDeprecated::defineConstants()
See also: PicoDeprecated::loadRootDirConfig()
See also: PicoDeprecated::enablePlugins()
See also: DummyPlugin::onConfigLoaded()
public onConfigLoaded ( array &$config ) : void
$config array
return void

onContentLoaded() public method

Triggers the deprecated event after_load_content($file, $rawContent)
See also: DummyPlugin::onContentLoaded()
public onContentLoaded ( &$rawContent )

onContentLoading() public method

Triggers the deprecated before_load_content($file)
See also: DummyPlugin::onContentLoading()
public onContentLoading ( &$file )

onContentParsed() public method

Triggers the deprecated events after_parse_content($content) and content_parsed($content)
See also: DummyPlugin::onContentParsed()
public onContentParsed ( &$content )

onContentParsing() public method

Triggers the deprecated event before_parse_content($rawContent)
See also: DummyPlugin::onContentParsing()
public onContentParsing ( &$rawContent )

onMetaHeaders() public method

Triggers the deprecated event before_read_file_meta($headers)
See also: DummyPlugin::onMetaHeaders()
public onMetaHeaders ( array &$headers )
$headers array

onMetaParsed() public method

Triggers the deprecated event file_meta($meta)
See also: DummyPlugin::onMetaParsed()
public onMetaParsed ( array &$meta )
$meta array

onPageRendered() public method

Triggers the deprecated event after_render($output)
See also: DummyPlugin::onPageRendered()
public onPageRendered ( &$output )

onPageRendering() public method

Please note that the before_render() event gets $templateName passed without its file extension. The file extension is later added again.
See also: DummyPlugin::onPageRendering()
public onPageRendering ( Twig_Environment &$twig, array &$twigVariables, &$templateName )
$twig Twig_Environment
$twigVariables array

onPagesLoaded() public method

Please note that the get_pages() event gets $pages passed without a array index. The index is rebuild later using either the id array key or is derived from the url array key. Duplicates are prevented by adding ~dup when necessary.
See also: DummyPlugin::onPagesLoaded()
public onPagesLoaded ( array &$pages, array &$currentPage = null, array &$previousPage = null, array &$nextPage = null )
$pages array
$currentPage array
$previousPage array
$nextPage array

onPluginsLoaded() public method

Enables this plugin on demand and triggers the deprecated event plugins_loaded()
See also: DummyPlugin::onPluginsLoaded()
public onPluginsLoaded ( array &$plugins )
$plugins array

onRequestFile() public method

Sets PicoDeprecated::$requestFile to trigger the deprecated events after_load_content() and after_404_load_content()
See also: PicoDeprecated::onContentLoaded()
See also: PicoDeprecated::on404ContentLoaded()
See also: DummyPlugin::onRequestFile()
public onRequestFile ( &$file )

onRequestUrl() public method

Triggers the deprecated event request_url($url)
See also: DummyPlugin::onRequestUrl()
public onRequestUrl ( &$url )

onSinglePageLoaded() public method

Triggers the deprecated event get_page_data($pages, $meta)
See also: DummyPlugin::onSinglePageLoaded()
public onSinglePageLoaded ( array &$pageData )
$pageData array

onTwigRegistration() public method

Triggers the deprecated event before_twig_register()
See also: DummyPlugin::onTwigRegistration()
public onTwigRegistration ( )

triggerEvent() protected method

Deprecated events are also triggered on plugins which implement {@link PicoPluginInterface}. Please note that the methods are called directly and not through {@link PicoPluginInterface::handleEvent()}.
protected triggerEvent ( string $eventName, array $params = [] ) : void
$eventName string event to trigger
$params array parameters to pass
return void

Property Details

$enabled protected property

This plugin is disabled by default
See also: AbstractPicoPlugin::$enabled
protected $enabled

$requestFile protected property

The requested file
See also: PicoDeprecated::getRequestFile()
protected string|null $requestFile
return string | null