8000 [Form] Further tweaks of the twig theme inheritance · 77web/symfony@5060702 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5060702

Browse files
committed
[Form] Further tweaks of the twig theme inheritance
1 parent bee505a commit 5060702

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/Symfony/Bridge/Twig/Extension/FormExtension.php

Copy file name to clipboard
Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ protected function render(FormView $view, $section, array $variables = array())
236236
/**
237237
* Returns the templates used by the view.
238238
*
239-
* templates are looked for in the following resources:
239+
* Templates are looked for in the resources in the following order:
240240
* * resources from the themes (and its parents)
241+
* * resources from the themes of parent views (up to the root view)
241242
* * default resources
242243
*
243244
* @param FormView $view The view
@@ -247,31 +248,25 @@ protected function render(FormView $view, $section, array $variables = array())
247248
protected function getTemplates(FormView $view)
248249
{
249250
if (!$this->templates->contains($view)) {
250-
// defaults
251-
$all = array();
252-
253-
// themes
251+
$resources = array();
254252
$parent = $view;
255253
do {
256254
if (isset($this->themes[$parent])) {
257-
$all = array_merge($this->themes[$parent], $all);
255+
$resources = array_merge($this->themes[$parent], $resources);
258256
}
259257
} while ($parent = $parent->getParent());
260258

261-
$all = array_merge($this->resources, $all);
259+
$resources = array_merge($this->resources, $resources);
262260

263261
$templates = array();
264-
foreach ($all as $resource) {
262+
foreach ($resources as $resource) {
265263
if (!$resource instanceof \Twig_Template) {
266264
$resource = $this->environment->loadTemplate($resource);
267265
}
268266

269-
$blocks = array();
270267
foreach ($this->getBlockNames($resource) as $name) {
271-
$blocks[$name] = $resource;
268+
$templates[$name] = $resource;
272269
}
273-
274-
$templates = array_replace($templates, $blocks);
275270
}
276271

277272
$this->templates->attach($view, $templates);

0 commit comments

Comments
 (0)
0