Skip to content

Commit

Permalink
bug silexphp#120 Add twig-bundle support (skalpa)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.0.x-dev branch.

Discussion
----------

Add twig-bundle support

Adds `symfony/twig-bundle` to the list of dependencies and registers the `@Twig` templates namespace.

- This fixes silexphp#109 and closes silexphp#110
- It also _fixes_ the exception page (eg: on `3.3` we get the fancy new page 😄 )

Commits
-------

3fb1f23 Added twig-bundle support
  • Loading branch information
fabpot committed Apr 4, 2018
2 parents 0b56bca + 3fb1f23 commit 57488d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions WebProfilerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ public function register(Container $app)

$app->extend('twig.loader.filesystem', function ($loader, $app) {
$loader->addPath($app['profiler.templates_path'], 'WebProfiler');
$loader->addPath($app['profiler.templates_path.twig'], 'Twig');
if ($app['profiler.templates_path.debug']) {
$loader->addPath($app['profiler.templates_path.debug'], 'Debug');
}
Expand All @@ -322,6 +323,12 @@ public function register(Container $app)
return dirname(dirname($r->getFileName())).'/Resources/views';
};

$app['profiler.templates_path.twig'] = function () {
$r = new \ReflectionClass('Symfony\Bundle\TwigBundle\Controller\ExceptionController');

return dirname(dirname($r->getFileName())).'/Resources/views';
};

$app['profiler.templates_path.debug'] = function () {
// This code cannot be simplified as all classes in the bundle depend
// on packages that are not required by Silex
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": {
"silex/silex": "^2.0",
"symfony/web-profiler-bundle": "^2.8|^3.0",
"symfony/twig-bundle": "^2.8|^3.0",
"symfony/twig-bridge": "^2.8|^3.0",
"symfony/stopwatch": "^2.8|^3.0"
},
Expand Down

0 comments on commit 57488d3

Please sign in to comment.