Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #2311 Add a simple Twig_RuntimeLoaderInterface implementation…
… (chalasr) This PR was merged into the 1.x branch. Discussion ---------- Add a simple Twig_RuntimeLoaderInterface implementation Next to symfony/symfony#21023 This is related to the BC break reported in symfony/symfony#21008 which has been introduced in symfony/symfony#20093 when decoupling extensions from definitions. What I propose here is to ease the upgrade to symfony 3.2+ by adding a simple `Twig_RuntimeLoaderInterface` implementation here, useful only when using the twig-bridge outside of the symfony fullstack framework (with the Form component for instance). Upgrading would be as simple as: ```diff $twig = new Twig_Environment(...); $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig); - $twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager))); + $twig->addExtension(new FormExtension()); + $twig->addRuntimeLoader(new Twig_RuntimeLoader(array(TwigRenderer::class => new TwigRenderer($rendererEngine, $csrfTokenManager))); ``` Instead of having to write this runtime loader yourself. Please see symfony/symfony#21008 for details and a concrete example of how this could help. Commits ------- 91c8d59 Add a Twig_FactoryRuntimeLoader
- Loading branch information