Commit da16dfb1 authored by Fabien Potencier's avatar Fabien Potencier

feature #976 added a simple way to override the Twig environment instance (fabpot)

This PR was merged into the 2.0.x-dev branch.

Discussion
----------

added a simple way to override the Twig environment instance

should fix #893

Commits
-------

fcc76b56 added a simple way to override the Twig environment instance
parents 06edabe3 fcc76b56
......@@ -44,7 +44,7 @@ class TwigServiceProvider implements ServiceProviderInterface
), $app['twig.options']
);
$twig = new \Twig_Environment($app['twig.loader'], $app['twig.options']);
$twig = $app['twig.environment_factory']($app);
$twig->addGlobal('app', $app);
if (isset($app['debug']) && $app['debug']) {
......@@ -105,5 +105,9 @@ class TwigServiceProvider implements ServiceProviderInterface
$app['twig.loader.filesystem'],
));
};
$app['twig.environment_factory'] = $app->protect(function ($app) {
return new \Twig_Environment($app['twig.loader'], $app['twig.options']);
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment