diff --git a/composer.json b/composer.json index 155e557b..765eb17d 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ ], "require": { "php": ">=5.4.0", - "twig/twig": "~1.15|~2.0", + "twig/twig": "~1.27|~2.0", "illuminate/support": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*", "illuminate/view": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*" }, diff --git a/src/Engine/Twig.php b/src/Engine/Twig.php index dfdfc347..cdfb055e 100644 --- a/src/Engine/Twig.php +++ b/src/Engine/Twig.php @@ -105,7 +105,7 @@ public function get($path, array $data = []) */ protected function handleTwigError(Twig_Error $ex) { - $templateFile = $ex->getTemplateFile(); + $templateFile = $ex->getSourceContext()->getPath(); $templateLine = $ex->getTemplateLine(); if ($templateFile && file_exists($templateFile)) { diff --git a/src/Twig/Loader.php b/src/Twig/Loader.php index 018fd350..5d72d625 100644 --- a/src/Twig/Loader.php +++ b/src/Twig/Loader.php @@ -11,7 +11,7 @@ namespace TwigBridge\Twig; -use Twig_LoaderInterface; +use Twig_SourceContextLoaderInterface; use Twig_Error_Loader; use Twig_ExistsLoaderInterface; use InvalidArgumentException; @@ -21,7 +21,7 @@ /** * Basic loader using absolute paths. */ -class Loader implements Twig_LoaderInterface, Twig_ExistsLoaderInterface +class Loader implements Twig_SourceContextLoaderInterface, Twig_ExistsLoaderInterface { /** * @var \Illuminate\Filesystem\Filesystem @@ -116,9 +116,11 @@ public function exists($name) /** * {@inheritdoc} */ - public function getSource($name) + public function getSourceContext($name) { - return $this->files->get($this->findTemplate($name)); + $path = $this->findTemplate($name); + + return new \Twig_Source($this->files->get($path), $name, $path); } /**