diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-12-03 23:39:50 +0100 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2019-07-08 01:58:06 +0200 |
commit | e9f157ec5ccdfae73b4c9e82c9ae7c37bcfa1513 (patch) | |
tree | fea2fdb1df183008f31f7827d9f83a5f6fc13cfb /src/Renderer/TwigEngine.php | |
parent | bcce2625a8cb0b630d945c6849014049869e10ce (diff) |
Renderer: Added shared data
Diffstat (limited to 'src/Renderer/TwigEngine.php')
-rw-r--r-- | src/Renderer/TwigEngine.php | 8 |
1 files changed, 5 insertions, 3 deletions
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); } |