mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-02 03:16:11 +01:00
Added support for Twig 2.11 (1.40 compatible)
This commit is contained in:
@@ -2,8 +2,9 @@
|
|||||||
## mm/dd/2019
|
## mm/dd/2019
|
||||||
|
|
||||||
1. [](#new)
|
1. [](#new)
|
||||||
* Require Grav v1.7
|
* Require Grav v1.7
|
||||||
* Use PSR-4 for plugin classes
|
* Use PSR-4 for plugin classes
|
||||||
|
* Added support for Twig 2.11
|
||||||
|
|
||||||
# v1.9.5
|
# v1.9.5
|
||||||
## mm/dd/2019
|
## mm/dd/2019
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ use PicoFeed\Parser\MalformedXmlException;
|
|||||||
use RocketTheme\Toolbox\Event\Event;
|
use RocketTheme\Toolbox\Event\Event;
|
||||||
use RocketTheme\Toolbox\File\File;
|
use RocketTheme\Toolbox\File\File;
|
||||||
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
||||||
|
use Twig\Loader\FilesystemLoader;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2019,7 +2020,7 @@ class AdminController extends AdminBaseController
|
|||||||
|
|
||||||
// Add theme template paths to Twig loader
|
// Add theme template paths to Twig loader
|
||||||
$template_paths = $this->grav['locator']->findResources('theme://templates');
|
$template_paths = $this->grav['locator']->findResources('theme://templates');
|
||||||
$this->grav['twig']->twig->getLoader()->addLoader(new \Twig_Loader_Filesystem($template_paths));
|
$this->grav['twig']->twig->getLoader()->addLoader(new FilesystemLoader($template_paths));
|
||||||
|
|
||||||
$html = $page->content();
|
$html = $page->content();
|
||||||
|
|
||||||
|
|||||||
@@ -6,17 +6,16 @@ use Grav\Common\Grav;
|
|||||||
use Grav\Common\Page\Interfaces\PageInterface;
|
use Grav\Common\Page\Interfaces\PageInterface;
|
||||||
use Grav\Common\Yaml;
|
use Grav\Common\Yaml;
|
||||||
use Grav\Common\Language\Language;
|
use Grav\Common\Language\Language;
|
||||||
|
use Twig\Extension\AbstractExtension;
|
||||||
|
use Twig\TwigFilter;
|
||||||
|
use Twig\TwigFunction;
|
||||||
|
|
||||||
class AdminTwigExtension extends \Twig_Extension
|
class AdminTwigExtension extends AbstractExtension
|
||||||
{
|
{
|
||||||
/**
|
/** @var Grav */
|
||||||
* @var Grav
|
|
||||||
*/
|
|
||||||
protected $grav;
|
protected $grav;
|
||||||
|
|
||||||
/**
|
/** @var Language $lang */
|
||||||
* @var Language $lang
|
|
||||||
*/
|
|
||||||
protected $lang;
|
protected $lang;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@@ -25,22 +24,22 @@ class AdminTwigExtension extends \Twig_Extension
|
|||||||
$this->lang = $this->grav['user']->language;
|
$this->lang = $this->grav['user']->language;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFilters()
|
public function getFilters(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new \Twig_SimpleFilter('tu', [$this, 'tuFilter']),
|
new TwigFilter('tu', [$this, 'tuFilter']),
|
||||||
new \Twig_SimpleFilter('toYaml', [$this, 'toYamlFilter']),
|
new TwigFilter('toYaml', [$this, 'toYamlFilter']),
|
||||||
new \Twig_SimpleFilter('fromYaml', [$this, 'fromYamlFilter']),
|
new TwigFilter('fromYaml', [$this, 'fromYamlFilter']),
|
||||||
new \Twig_SimpleFilter('adminNicetime', [$this, 'adminNicetimeFilter']),
|
new TwigFilter('adminNicetime', [$this, 'adminNicetimeFilter']),
|
||||||
new \Twig_SimpleFilter('nested', [$this, 'nestedFilter']),
|
new TwigFilter('nested', [$this, 'nestedFilter']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFunctions()
|
public function getFunctions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new \Twig_SimpleFunction('getPageUrl', [$this, 'getPageUrl'], ['needs_context' => true]),
|
new TwigFunction('getPageUrl', [$this, 'getPageUrl'], ['needs_context' => true]),
|
||||||
new \Twig_SimpleFunction('clone', [$this, 'cloneFunc']),
|
new TwigFunction('clone', [$this, 'cloneFunc']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user