merged branch fabpot/twig-form-renderer-fix (PR #9010)
This PR was merged into the 2.2 branch.
Discussion
----------
[TwigBridge] fixed form rendering when used in a template with dynamic inheritance
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #5284
| License | MIT
| Doc PR | n/a
Commits
-------
4c1dbc7
[TwigBridge] fixed form rendering when used in a template with dynamic inheritance
This commit is contained in:
commit
8e5a9b056c
@ -167,6 +167,8 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE
|
|||||||
// theme is a reference and we don't want to change it.
|
// theme is a reference and we don't want to change it.
|
||||||
$currentTheme = $theme;
|
$currentTheme = $theme;
|
||||||
|
|
||||||
|
$context = $this->environment->mergeGlobals(array());
|
||||||
|
|
||||||
// The do loop takes care of template inheritance.
|
// The do loop takes care of template inheritance.
|
||||||
// Add blocks from all templates in the inheritance tree, but avoid
|
// Add blocks from all templates in the inheritance tree, but avoid
|
||||||
// overriding blocks already set.
|
// overriding blocks already set.
|
||||||
@ -178,6 +180,6 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE
|
|||||||
$this->resources[$cacheKey][$block] = $blockData;
|
$this->resources[$cacheKey][$block] = $blockData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (false !== $currentTheme = $currentTheme->getParent(array()));
|
} while (false !== $currentTheme = $currentTheme->getParent($context));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,8 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||||||
$environment = new \Twig_Environment($loader, array('strict_variables' => true));
|
$environment = new \Twig_Environment($loader, array('strict_variables' => true));
|
||||||
$environment->addExtension(new TranslationExtension(new StubTranslator()));
|
$environment->addExtension(new TranslationExtension(new StubTranslator()));
|
||||||
$environment->addGlobal('global', '');
|
$environment->addGlobal('global', '');
|
||||||
|
// the value can be any template that exists
|
||||||
|
$environment->addGlobal('dynamic_template_name', 'child_label');
|
||||||
$environment->addExtension($this->extension);
|
$environment->addExtension($this->extension);
|
||||||
|
|
||||||
$this->extension->initRuntime($environment);
|
$this->extension->initRuntime($environment);
|
||||||
@ -106,6 +108,18 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testThemeBlockInheritanceUsingDynamicExtend()
|
||||||
|
{
|
||||||
|
$view = $this->factory
|
||||||
|
->createNamed('name', 'email')
|
||||||
|
->createView()
|
||||||
|
;
|
||||||
|
|
||||||
|
$renderer = $this->extension->renderer;
|
||||||
|
$renderer->setTheme($view, array('page_dynamic_extends.html.twig'));
|
||||||
|
$renderer->searchAndRenderBlock($view, 'row');
|
||||||
|
}
|
||||||
|
|
||||||
public function isSelectedChoiceProvider()
|
public function isSelectedChoiceProvider()
|
||||||
{
|
{
|
||||||
// The commented cases should not be necessary anymore, because the
|
// The commented cases should not be necessary anymore, because the
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{% extends dynamic_template_name ~ '.html.twig' %}
|
Reference in New Issue
Block a user