Various small improvements

This commit is contained in:
Daniel Rudolf 2020-04-11 21:15:50 +02:00
parent bdafcb5b96
commit 646aa355e5
No known key found for this signature in database
GPG key ID: A061F02CD8DE4538
3 changed files with 16 additions and 11 deletions

View file

@ -1559,8 +1559,11 @@ class Pico
public function getParsedown()
{
if ($this->parsedown === null) {
$className = $this->config['content_config']['extra'] ? '\ParsedownExtra' : '\Parsedown';
$this->parsedown = new $className();
if ($this->config['content_config']['extra']) {
$this->parsedown = new \ParsedownExtra();
} else {
$this->parsedown = new \Parsedown();
}
$this->parsedown->setBreaksEnabled((bool) $this->config['content_config']['breaks']);
$this->parsedown->setMarkupEscaped((bool) $this->config['content_config']['escape']);

View file

@ -14,6 +14,7 @@ namespace picocms\Pico;
use Twig\Error\RuntimeError as TwigRuntimeError;
use Twig\Extension\AbstractExtension as AbstractTwigExtension;
use Twig\Extension\ExtensionInterface as TwigExtensionInterface;
use Twig\TwigFilter;
use Twig\TwigFunction;
@ -60,7 +61,7 @@ class TwigExtension extends AbstractTwigExtension
/**
* Returns the name of the extension
*
* @see Twig_ExtensionInterface::getName()
* @see TwigExtensionInterface::getName()
*
* @return string the extension name
*/
@ -72,7 +73,7 @@ class TwigExtension extends AbstractTwigExtension
/**
* Returns a list of Pico-specific Twig filters
*
* @see Twig_ExtensionInterface::getFilters()
* @see TwigExtensionInterface::getFilters()
*
* @return TwigFilter[] array of Pico's Twig filters
*/
@ -94,7 +95,7 @@ class TwigExtension extends AbstractTwigExtension
/**
* Returns a list of Pico-specific Twig functions
*
* @see Twig_ExtensionInterface::getFunctions()
* @see TwigExtensionInterface::getFunctions()
*
* @return TwigFunction[] array of Pico's Twig functions
*/
@ -406,7 +407,7 @@ class TwigExtension extends AbstractTwigExtension
* returns Pico's full pages array.
*
* If `$depth` is negative after taking `$offset` into consideration, the
* function will throw a {@see Twig_Error_Runtime} exception, since this
* function will throw a {@see TwigRuntimeError} exception, since this
* would simply make no sense and is likely an error. Passing a negative
* `$depthOffset` is equivalent to passing `$depthOffset = 0`.
*

View file

@ -12,6 +12,7 @@
use picocms\Pico\AbstractPlugin;
use picocms\Pico\Pico;
use Twig\Environment as TwigEnvironment;
/**
* Pico dummy plugin - a template for plugins
@ -31,7 +32,7 @@ class DummyPlugin extends AbstractPlugin
*
* @var int
*/
const API_VERSION = 3;
public const API_VERSION = 3;
/**
* This plugin is disabled by default
@ -39,8 +40,8 @@ class DummyPlugin extends AbstractPlugin
* 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
* {@see DummyPlugin::$dependsOn}), Pico enables the plugin by default.
* Otherwise the plugin is silently disabled.
* {@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
@ -498,9 +499,9 @@ class DummyPlugin extends AbstractPlugin
*
* @see Pico::getTwig()
*
* @param Twig_Environment &$twig Twig instance
* @param TwigEnvironment &$twig Twig instance
*/
public function onTwigRegistered(Twig_Environment &$twig)
public function onTwigRegistered(TwigEnvironment &$twig)
{
// your code
}