Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.*"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function get($path, array $data = [])
*/
protected function handleTwigError(Twig_Error $ex)
{
$templateFile = $ex->getTemplateFile();
$templateFile = $ex->getSourceContext()->getPath();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this possible for all exceptions?

$templateLine = $ex->getTemplateLine();

if ($templateFile && file_exists($templateFile)) {
Expand Down
10 changes: 6 additions & 4 deletions src/Twig/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace TwigBridge\Twig;

use Twig_LoaderInterface;
use Twig_SourceContextLoaderInterface;
use Twig_Error_Loader;
use Twig_ExistsLoaderInterface;
use InvalidArgumentException;
Expand All @@ -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
Expand Down Expand Up @@ -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);
}

/**
Expand Down