Commit 8ddc094b authored by Fabien Potencier's avatar Fabien Potencier

bug #1612 Check for HttpKernelRuntime before using it in Twig runtimes (hkdobrev)

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

Discussion
----------

Check for HttpKernelRuntime before using it in Twig runtimes

Fixes #1448.

This fixes an incompatibility with Symfony Twig bridge prior to 3.2.

The HttpKernelRuntime was introduced in https://github.com/silexphp/Silex/commit/72d7746ec216da230221c19aa6e3092b55596070.
It included checks whether the class exists, but not in the Twig runtimes list.

Commits
-------

18ab3f6e Check for HttpKernelRuntime before using it in Twig runtimes
parents 2a7e41fc 18ab3f6e
...@@ -192,9 +192,11 @@ class TwigServiceProvider implements ServiceProviderInterface ...@@ -192,9 +192,11 @@ class TwigServiceProvider implements ServiceProviderInterface
}; };
$app['twig.runtimes'] = function ($app) { $app['twig.runtimes'] = function ($app) {
$runtimes = [ $runtimes = [];
HttpKernelRuntime::class => 'twig.runtime.httpkernel',
]; if (class_exists(HttpKernelRuntime::class)) {
$runtimes[HttpKernelRuntime::class] = 'twig.runtime.httpkernel';
}
if (Kernel::VERSION_ID < 30400) { if (Kernel::VERSION_ID < 30400) {
$runtimes[TwigRenderer::class] = 'twig.form.renderer'; $runtimes[TwigRenderer::class] = 'twig.form.renderer';
......
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