fix(php8): be compatible
add config to be sure to keep compatible php 7.2.5
This commit is contained in:
parent
efa51f66b1
commit
59a8859e1c
3 changed files with 28 additions and 13 deletions
|
@ -31,7 +31,7 @@
|
|||
"source": "https://github.com/picocms/Pico"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"php": ">=7.2.5||^8.0",
|
||||
"ext-mbstring": "*",
|
||||
"twig/twig": "^3.3.8",
|
||||
"symfony/yaml" : "^5.4.3",
|
||||
|
@ -56,5 +56,15 @@
|
|||
"dev-master": "2.1.x-dev",
|
||||
"dev-pico-3.0": "3.0.x-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.2.5"
|
||||
},
|
||||
"platform-check": true,
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"picocms/composer-installer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
10
lib/Pico.php
10
lib/Pico.php
|
@ -2147,12 +2147,12 @@ class Pico
|
|||
if ($this->twig === null) {
|
||||
$twigConfig = $this->getConfig('twig_config');
|
||||
|
||||
$twigLoader = new TwigFilesystemLoader($this->getThemesDir() . $this->getTheme());
|
||||
$this->twig = new TwigEnvironment($twigLoader, $twigConfig);
|
||||
$twigLoader = new \Twig\Loader\FilesystemLoader($this->getThemesDir() . $this->getTheme());
|
||||
$this->twig = new \Twig\Environment($twigLoader, $twigConfig);
|
||||
$this->twig->addExtension(new PicoTwigExtension($this));
|
||||
|
||||
if (!empty($twigConfig['debug'])) {
|
||||
$this->twig->addExtension(new TwigDebugExtension());
|
||||
$this->twig->addExtension(new Twig\Extension\DebugExtension());
|
||||
}
|
||||
|
||||
// register content filter
|
||||
|
@ -2160,7 +2160,7 @@ class Pico
|
|||
// this is the reason why we can't register this filter as part of PicoTwigExtension
|
||||
$pico = $this;
|
||||
$pages = &$this->pages;
|
||||
$this->twig->addFilter(new TwigFilter(
|
||||
$this->twig->addFilter(new \Twig\TwigFilter(
|
||||
'content',
|
||||
function ($page) use ($pico, &$pages) {
|
||||
if (isset($pages[$page])) {
|
||||
|
@ -2201,7 +2201,7 @@ class Pico
|
|||
'theme_url' => $this->getConfig('themes_url') . $this->getTheme(),
|
||||
'site_title' => $this->getConfig('site_title'),
|
||||
'meta' => $this->meta,
|
||||
'content' => new TwigMarkup($this->content, 'UTF-8'),
|
||||
'content' => new \Twig\Markup($this->content, 'UTF-8'),
|
||||
'pages' => $this->pages,
|
||||
'previous_page' => $this->previousPage,
|
||||
'current_page' => $this->currentPage,
|
||||
|
|
|
@ -75,16 +75,21 @@ class PicoTwigExtension extends AbstractTwigExtension
|
|||
*
|
||||
* @see TwigExtensionInterface::getFilters()
|
||||
*
|
||||
* @return TwigFilter[] array of Pico's Twig filters
|
||||
* @return \Twig\TwigFilter[] array of Pico's Twig filters
|
||||
*/
|
||||
public function getFilters(): array
|
||||
{
|
||||
return [
|
||||
'markdown' => new TwigFilter('markdown', [ $this, 'markdownFilter' ], [ 'is_safe' => [ 'html' ] ]),
|
||||
'sort_by' => new TwigFilter('sort_by', [ $this, 'sortByFilter' ]),
|
||||
'link' => new TwigFilter('link', [ $this->pico, 'getPageUrl' ]),
|
||||
'url' => new TwigFilter('url', [ $this->pico, 'substituteUrl' ]),
|
||||
];
|
||||
return array(
|
||||
'markdown' => new \Twig\TwigFilter(
|
||||
'markdown',
|
||||
array($this, 'markdownFilter'),
|
||||
array('is_safe' => array('html'))
|
||||
),
|
||||
'map' => new \Twig\TwigFilter('map', array($this, 'mapFilter')),
|
||||
'sort_by' => new \Twig\TwigFilter('sort_by', array($this, 'sortByFilter')),
|
||||
'link' => new \Twig\TwigFilter('link', array($this->pico, 'getPageUrl')),
|
||||
'url' => new \Twig\TwigFilter('url', array($this->pico, 'substituteUrl'))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue