1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-18 02:41:27 +02:00

feat(core): add CacheTwigExtension #309

This commit is contained in:
Awilum
2019-11-22 22:40:21 +03:00
parent b1cfd7f376
commit f0b05700cf
2 changed files with 42 additions and 0 deletions

View File

@@ -229,6 +229,9 @@ $flextype['view'] = static function ($container) {
// Add Twig Debug Extension
$view->addExtension(new DebugExtension());
// Add Cache Twig Extension
$view->addExtension(new CacheTwigExtension($container));
// Add Entries Twig Extension
$view->addExtension(new EntriesTwigExtension($container));

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
/**
* Flextype (http://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/
namespace Flextype;
use Twig_Extension;
use Twig_Extension_GlobalsInterface;
class CacheTwigExtension extends Twig_Extension implements Twig_Extension_GlobalsInterface
{
/**
* Flextype Dependency Container
*/
private $flextype;
/**
* Constructor
*/
public function __construct($flextype)
{
$this->flextype = $flextype;
}
/**
* Register Global variables in an extension
*/
public function getGlobals()
{
return [
'cache' => $this->flextype['cache'],
];
}
}