Various small improvements

This commit is contained in:
Daniel Rudolf 2017-05-13 18:17:58 +02:00
parent 191f6edbe9
commit 624310bbe7
No known key found for this signature in database
GPG Key ID: A061F02CD8DE4538
4 changed files with 74 additions and 62 deletions

View File

@ -154,7 +154,7 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface
* config variable, null if the config variable doesn't exist or the * config variable, null if the config variable doesn't exist or the
* plugin's config array if no config name was supplied * plugin's config array if no config name was supplied
*/ */
protected function getPluginConfig($configName = null) public function getPluginConfig($configName = null)
{ {
$pluginConfig = $this->getConfig(get_called_class()); $pluginConfig = $this->getConfig(get_called_class());
if ($pluginConfig) { if ($pluginConfig) {
@ -263,8 +263,8 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface
} }
} }
} else { } else {
$dependantsList = 'plugin' . ((count($dependants) > 1) ? 's' : '') . ' '; $dependantsList = 'plugin' . ((count($dependants) > 1) ? 's' : '') . ' '
$dependantsList .= "'" . implode("', '", array_keys($dependants)) . "'"; . "'" . implode("', '", array_keys($dependants)) . "'";
throw new RuntimeException( throw new RuntimeException(
"Unable to disable plugin '" . get_called_class() . "': " "Unable to disable plugin '" . get_called_class() . "': "
. "Required by " . $dependantsList . "Required by " . $dependantsList

View File

@ -274,7 +274,7 @@ class Pico
/** /**
* Constructs a new Pico instance * Constructs a new Pico instance
* *
* To carry out all the processing in Pico, call {@link Pico::run()}. * To carry out all the processing in Pico, call {@see Pico::run()}.
* *
* @param string $rootDir root directory of this Pico instance * @param string $rootDir root directory of this Pico instance
* @param string $configDir config directory of this Pico instance * @param string $configDir config directory of this Pico instance
@ -677,8 +677,8 @@ class Pico
/** /**
* Returns the instance of a named plugin * Returns the instance of a named plugin
* *
* Plugins SHOULD implement {@link PicoPluginInterface}, but you MUST NOT * Plugins SHOULD implement {@see PicoPluginInterface}, but you MUST NOT
* rely on it. For more information see {@link PicoPluginInterface}. * rely on it. For more information see {@see PicoPluginInterface}.
* *
* @see Pico::loadPlugins() * @see Pico::loadPlugins()
* @see Pico::getPlugins() * @see Pico::getPlugins()
@ -824,8 +824,8 @@ class Pico
* {@path "config/config.yml"} or changing some of its variables before * {@path "config/config.yml"} or changing some of its variables before
* Pico starts processing. * Pico starts processing.
* *
* You can call this method between {@link Pico::__construct()} and * You can call this method between {@see Pico::__construct()} and
* {@link Pico::run()} only. Options set with this method cannot be * {@see Pico::run()} only. Options set with this method cannot be
* overwritten by {@path "config/config.yml"}. * overwritten by {@path "config/config.yml"}.
* *
* @see Pico::loadConfig() * @see Pico::loadConfig()
@ -1315,7 +1315,7 @@ class Pico
* The page data will be an array containing the following values: * The page data will be an array containing the following values:
* *
* | Array key | Type | Description | * | Array key | Type | Description |
* | -------------- | ------ | ---------------------------------------- | * | -------------- | ------- | ------------------------------------------ |
* | id | string | relative path to the content file | * | id | string | relative path to the content file |
* | url | string | URL to the page | * | url | string | URL to the page |
* | title | string | title of the page (YAML header) | * | title | string | title of the page (YAML header) |
@ -1324,11 +1324,16 @@ class Pico
* | time | string | timestamp derived from the Date header | * | time | string | timestamp derived from the Date header |
* | date | string | date of the page (YAML header) | * | date | string | date of the page (YAML header) |
* | date_formatted | string | formatted date of the page | * | date_formatted | string | formatted date of the page |
* | hidden | boolean | this page shouldn't be visible to the user |
* | raw_content | string | raw, not yet parsed contents of the page | * | raw_content | string | raw, not yet parsed contents of the page |
* | meta | string | parsed meta data of the page | * | meta | string | parsed meta data of the page |
* | previous_page | &array | reference to the previous page | * | previous_page | &array | reference to the previous page |
* | next_page | &array | reference to the next page | * | next_page | &array | reference to the next page |
* *
* Please note that the `previous_page` and `next_page` keys won't be
* available until the `onPagesLoaded` event ({@see Pico::sortPages()})
* was triggered.
*
* @see Pico::sortPages() * @see Pico::sortPages()
* @see Pico::discoverPageSiblings() * @see Pico::discoverPageSiblings()
* @see Pico::getPages() * @see Pico::getPages()
@ -1578,10 +1583,10 @@ class Pico
} }
/** /**
* Registers the twig template engine * Registers the Twig template engine
* *
* This method also registers Pico's core Twig filters `link` and `content` * This method also registers Pico's core Twig filters `link` and `content`
* as well as Pico's {@link PicoTwigExtension} Twig extension. * as well as Pico's {@see PicoTwigExtension} Twig extension.
* *
* This method triggers the `onTwigRegistered` event when the Twig template * This method triggers the `onTwigRegistered` event when the Twig template
* engine wasn't initiated yet. * engine wasn't initiated yet.
@ -1800,10 +1805,10 @@ class Pico
* We assume that the themes folder is a arbitrary deep sub folder of the * We assume that the themes folder is a arbitrary deep sub folder of the
* script's base path (i.e. the directory {@path "index.php"} is in resp. * script's base path (i.e. the directory {@path "index.php"} is in resp.
* the `httpdocs` directory). Usually the script's base path is identical * the `httpdocs` directory). Usually the script's base path is identical
* to {@link Pico::$rootDir}, but this may aberrate when Pico got installed * to {@see Pico::$rootDir}, but this may aberrate when Pico got installed
* as a composer dependency. However, ultimately it allows us to use * as a composer dependency. However, ultimately it allows us to use
* {@link Pico::getBaseUrl()} as origin of the theme URL. Otherwise Pico * {@see Pico::getBaseUrl()} as origin of the theme URL. Otherwise Pico
* falls back to the basename of {@link Pico::$themesDir} (i.e. assuming * falls back to the basename of {@see Pico::$themesDir} (i.e. assuming
* that `Pico::$themesDir` is `foo/bar/baz`, the base URL of the themes * that `Pico::$themesDir` is `foo/bar/baz`, the base URL of the themes
* folder will be `baz/`; this ensures BC to Pico < 2.0). Pico's base URL * folder will be `baz/`; this ensures BC to Pico < 2.0). Pico's base URL
* always gets prepended appropriately. * always gets prepended appropriately.
@ -1831,8 +1836,8 @@ class Pico
/** /**
* Filters a URL GET parameter with a specified filter * Filters a URL GET parameter with a specified filter
* *
* This method is just an alias for {@link Pico::filterVariable()}, see * This method is just an alias for {@see Pico::filterVariable()}, see
* {@link Pico::filterVariable()} for a detailed description. It can be * {@see Pico::filterVariable()} for a detailed description. It can be
* used in Twig templates by calling the `url_param` function. * used in Twig templates by calling the `url_param` function.
* *
* @see Pico::filterVariable() * @see Pico::filterVariable()
@ -1856,8 +1861,8 @@ class Pico
/** /**
* Filters a HTTP POST parameter with a specified filter * Filters a HTTP POST parameter with a specified filter
* *
* This method is just an alias for {@link Pico::filterVariable()}, see * This method is just an alias for {@see Pico::filterVariable()}, see
* {@link Pico::filterVariable()} for a detailed description. It can be * {@see Pico::filterVariable()} for a detailed description. It can be
* used in Twig templates by calling the `form_param` function. * used in Twig templates by calling the `form_param` function.
* *
* @see Pico::filterVariable() * @see Pico::filterVariable()

View File

@ -3,12 +3,12 @@
/** /**
* Common interface for Pico plugins * Common interface for Pico plugins
* *
* For a list of supported events see {@link DummyPlugin}; you can use * For a list of supported events see {@see DummyPlugin}; you can use
* {@link DummyPlugin} as template for new plugins. For a list of deprecated * {@see DummyPlugin} as template for new plugins. For a list of deprecated
* events see {@link PicoDeprecated}. * events see {@see PicoDeprecated}.
* *
* You SHOULD NOT use deprecated events when implementing this interface. * You SHOULD NOT use deprecated events when implementing this interface.
* Deprecated events are triggered by the {@link PicoDeprecated} plugin, if * Deprecated events are triggered by the {@see PicoDeprecated} plugin, if
* plugins which don't implement this interface are loaded. You can take * plugins which don't implement this interface are loaded. You can take
* advantage from this behaviour if you want to do something only when old * advantage from this behaviour if you want to do something only when old
* plugins are loaded. Consequently the old events are never triggered when * plugins are loaded. Consequently the old events are never triggered when

View File

@ -121,18 +121,6 @@ class DummyPlugin extends AbstractPicoPlugin
// your code // your code
} }
/**
* Triggered after Pico has read the contents of the file to serve
*
* @see Pico::getRawContent()
* @param string &$rawContent raw file contents
* @return void
*/
public function onContentLoaded(&$rawContent)
{
// your code
}
/** /**
* Triggered before Pico reads the contents of a 404 file * Triggered before Pico reads the contents of a 404 file
* *
@ -158,6 +146,22 @@ class DummyPlugin extends AbstractPicoPlugin
// your code // your code
} }
/**
* Triggered after Pico has read the contents of the file to serve
*
* If Pico serves a 404 file, this event is triggered with the raw contents
* of said 404 file. Use {@see Pico::is404Content()} to check for this
* case when necessary.
*
* @see Pico::getRawContent()
* @param string &$rawContent raw file contents
* @return void
*/
public function onContentLoaded(&$rawContent)
{
// your code
}
/** /**
* Triggered when Pico reads its known meta header fields * Triggered when Pico reads its known meta header fields
* *
@ -274,7 +278,7 @@ class DummyPlugin extends AbstractPicoPlugin
* The `$pageData` parameter consists of the following values: * The `$pageData` parameter consists of the following values:
* *
* | Array key | Type | Description | * | Array key | Type | Description |
* | -------------- | ------ | ---------------------------------------- | * | -------------- | ------- | ------------------------------------------ |
* | id | string | relative path to the content file | * | id | string | relative path to the content file |
* | url | string | URL to the page | * | url | string | URL to the page |
* | title | string | title of the page (YAML header) | * | title | string | title of the page (YAML header) |
@ -283,8 +287,11 @@ class DummyPlugin extends AbstractPicoPlugin
* | time | string | timestamp derived from the Date header | * | time | string | timestamp derived from the Date header |
* | date | string | date of the page (YAML header) | * | date | string | date of the page (YAML header) |
* | date_formatted | string | formatted date of the page | * | date_formatted | string | formatted date of the page |
* | hidden | boolean | this page shouldn't be visible to the user |
* | raw_content | string | raw, not yet parsed contents of the page | * | raw_content | string | raw, not yet parsed contents of the page |
* | meta | string | parsed meta data of the page | * | meta | string | parsed meta data of the page |
* | previous_page | &array | reference to the previous page |
* | next_page | &array | reference to the next page |
* *
* Set `$pageData` to `null` to remove this page from the pages array. * Set `$pageData` to `null` to remove this page from the pages array.
* *
@ -301,7 +308,7 @@ class DummyPlugin extends AbstractPicoPlugin
/** /**
* Triggered after Pico has discovered all known pages * Triggered after Pico has discovered all known pages
* *
* See {@link DummyPlugin::onSinglePageLoaded()} for details about the * See {@see DummyPlugin::onSinglePageLoaded()} for details about the
* structure of the page data. Please note that the pages array isn't * structure of the page data. Please note that the pages array isn't
* sorted yet. * sorted yet.
* *
@ -318,7 +325,7 @@ class DummyPlugin extends AbstractPicoPlugin
/** /**
* Triggered after Pico has sorted the pages array * Triggered after Pico has sorted the pages array
* *
* See {@link DummyPlugin::onSinglePageLoaded()} for details about the * See {@see DummyPlugin::onSinglePageLoaded()} for details about the
* structure of the page data. * structure of the page data.
* *
* @see Pico::getPages() * @see Pico::getPages()
@ -333,7 +340,7 @@ class DummyPlugin extends AbstractPicoPlugin
/** /**
* Triggered when Pico discovered the current, previous and next pages * Triggered when Pico discovered the current, previous and next pages
* *
* See {@link DummyPlugin::onSinglePageLoaded()} for details about the * See {@see DummyPlugin::onSinglePageLoaded()} for details about the
* structure of the page data. * structure of the page data.
* *
* @see Pico::discoverPageSiblings() * @see Pico::discoverPageSiblings()