Commit fcc76b56 authored by Fabien Potencier's avatar Fabien Potencier

added a simple way to override the Twig environment instance

parent f55a6739
......@@ -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