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:
@@ -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));
|
||||
|
||||
|
39
flextype/twig/CacheTwigExtension.php
Normal file
39
flextype/twig/CacheTwigExtension.php
Normal 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'],
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user