Skip to content
Snippets Groups Projects
Commit be3b5337 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2539258 by cilefen: Inject the cache bin into TwigEnvironment

parent e19e8efd
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -1418,7 +1418,7 @@ services:
class: Drupal\Core\Extension\InfoParser
twig:
class: Drupal\Core\Template\TwigEnvironment
arguments: ['@app.root', '@twig.loader', '%twig.config%']
arguments: ['@app.root', '@cache.default', '@twig.loader', '%twig.config%']
tags:
- { name: service_collector, tag: 'twig.extension', call: addExtension }
twig.extension:
......
......@@ -8,6 +8,7 @@
namespace Drupal\Core\Template;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\PhpStorage\PhpStorageFactory;
use Drupal\Core\Render\SafeString;
......@@ -36,14 +37,15 @@ class TwigEnvironment extends \Twig_Environment {
*
* @param string $root
* The app root.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache
* The cache bin.
* @param \Twig_LoaderInterface $loader
* The Twig loader or loader chain.
* @param array $options
* The options for the Twig environment.
*/
public function __construct($root, \Twig_LoaderInterface $loader = NULL, $options = array()) {
// @todo Pass as arguments from the DIC.
$this->cache_object = \Drupal::cache();
public function __construct($root, CacheBackendInterface $cache, \Twig_LoaderInterface $loader = NULL, $options = array()) {
$this->cache_object = $cache;
// Ensure that twig.engine is loaded, given that it is needed to render a
// template because functions like TwigExtension::escapeFilter() are called.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment