From 04872f3cf6b70653557d49ac9df7b80419861aec Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 8 Jul 2024 00:00:00 +0000 Subject: [PATCH] Fixed injection of module templates in theme with duplicate names (fix #2200). --- application/src/Service/ThemeManagerFactory.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/application/src/Service/ThemeManagerFactory.php b/application/src/Service/ThemeManagerFactory.php index 40a4a8e41..6b40de655 100644 --- a/application/src/Service/ThemeManagerFactory.php +++ b/application/src/Service/ThemeManagerFactory.php @@ -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); }