From e9f157ec5ccdfae73b4c9e82c9ae7c37bcfa1513 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Mon, 3 Dec 2018 23:39:50 +0100 Subject: Renderer: Added shared data --- src/Renderer/TwigEngine.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Renderer/TwigEngine.php') diff --git a/src/Renderer/TwigEngine.php b/src/Renderer/TwigEngine.php index 55a2e299..aa51a177 100644 --- a/src/Renderer/TwigEngine.php +++ b/src/Renderer/TwigEngine.php @@ -7,7 +7,7 @@ use Twig_Error_Loader as LoaderError; use Twig_Error_Runtime as RuntimeError; use Twig_Error_Syntax as SyntaxError; -class TwigEngine implements EngineInterface +class TwigEngine extends Engine { /** @var Twig */ protected $twig; @@ -25,8 +25,10 @@ class TwigEngine implements EngineInterface * @return string * @throws LoaderError|RuntimeError|SyntaxError */ - public function get($path, $data = []) + public function get(string $path, array $data = []): string { + $data = array_replace_recursive($this->sharedData, $data); + return $this->twig->render($path, $data); } @@ -34,7 +36,7 @@ class TwigEngine implements EngineInterface * @param string $path * @return bool */ - public function canRender($path) + public function canRender(string $path): bool { return $this->twig->getLoader()->exists($path); } -- cgit v1.2.3-54-g00ecf