Skip to content

Commit

Permalink
Merge pull request #2210 from Daniel-KM/fix/module_template_theme
Browse files Browse the repository at this point in the history
Fixed injection of module templates in theme with duplicate names (fix #2200).
  • Loading branch information
zerocrates authored Jul 15, 2024
2 parents 284af28 + 04872f3 commit d816da2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions application/src/Service/ThemeManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,19 @@ public function __invoke(ContainerInterface $serviceLocator, $requestedName, arr

$theme->setState(ThemeManager::STATE_ACTIVE);

// Inject module templates.
// Inject module templates, with priority to theme templates.
// Take care of merge with duplicate template keys.
if (count($modulePageTemplates)) {
$configSpec['page_templates'] = empty($configSpec['page_templates'])
? $modulePageTemplates
: array_merge_recursive($configSpec['page_templates'], $modulePageTemplates);
: array_replace($modulePageTemplates, $configSpec['page_templates']);
}
if (count($moduleBlockTemplates)) {
$configSpec['block_templates'] = empty($configSpec['block_templates'])
? $moduleBlockTemplates
: array_merge_recursive($configSpec['block_templates'], $moduleBlockTemplates);
// Array_merge_recursive() converts duplicate keys to array.
// Array_map() removes keys.
: array_replace_recursive($moduleBlockTemplates, $configSpec['block_templates']);
}
$theme->setConfigSpec($configSpec);
}
Expand Down

0 comments on commit d816da2

Please sign in to comment.