Skip to content

Commit

Permalink
Merge pull request #6004 from GawainLynch/hotfix/twig-1.27
Browse files Browse the repository at this point in the history
Fix for Twig ^1.27
  • Loading branch information
bobdenotter authored Nov 10, 2016
2 parents 7dcab75 + 4a79405 commit 421045f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"symfony/web-profiler-bundle" : "^2.8",
"symfony/yaml" : "^2.8",
"tdammers/htmlmaid" : "~0.7",
"twig/twig" : "<1.26",
"twig/twig" : "^1.27",
"ua-parser/uap-php" : "~3.4"
},
"require-dev" : {
Expand Down
11 changes: 11 additions & 0 deletions src/Twig/FilesystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Bolt\Filesystem\Handler\DirectoryInterface;
use Bolt\Filesystem\Handler\FileInterface;
use Twig_Error_Loader as LoaderError;
use Twig_Source as TwigSource;

/**
* Loads templates from a Bolt\Filesystem interface.
Expand Down Expand Up @@ -46,6 +47,16 @@ public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
$this->prependDir($this->filesystem->getDir($path), $namespace);
}

/**
* {@inheritdoc}
*/
public function getSourceContext($name)
{
$file = $this->findTemplate($name);

return new TwigSource($file->read(), $name, $file->getFullPath());
}

/**
* Adds a directory where templates are stored.
*
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/unit/Twig/SetcontentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public function testParse()
$twigParser = new TwigParserMock($app['twig']);
$twigParser->setStream($twigTokenStream);

$expression = new Twig_ExpressionParser($twigParser, ['='], []);
$env = $app['twig'];
$expression = new Twig_ExpressionParser($twigParser, $env);
$twigParser->setExpressionParser($expression);

$setContentParser = new SetcontentTokenParser();
Expand Down

0 comments on commit 421045f

Please sign in to comment.