diff --git a/application/config/module.config.php b/application/config/module.config.php index 9f11b53d9..db1deac12 100644 --- a/application/config/module.config.php +++ b/application/config/module.config.php @@ -746,6 +746,8 @@ ], ], ], + 'page_templates' => [], + 'block_templates' => [], 'block_layouts' => [ 'invokables' => [ 'pageTitle' => Site\BlockLayout\PageTitle::class, diff --git a/application/src/Service/ThemeManagerFactory.php b/application/src/Service/ThemeManagerFactory.php index 5102e41d0..40a4a8e41 100644 --- a/application/src/Service/ThemeManagerFactory.php +++ b/application/src/Service/ThemeManagerFactory.php @@ -14,6 +14,11 @@ class ThemeManagerFactory implements FactoryInterface { public function __invoke(ContainerInterface $serviceLocator, $requestedName, array $options = null) { + // Prepare injection of module templates. + $config = $serviceLocator->get('Config'); + $modulePageTemplates = $config['page_templates']; + $moduleBlockTemplates = $config['block_templates']; + $manager = new ThemeManager; $iniReader = new IniReader; @@ -62,6 +67,19 @@ public function __invoke(ContainerInterface $serviceLocator, $requestedName, arr } $theme->setState(ThemeManager::STATE_ACTIVE); + + // Inject module templates. + if (count($modulePageTemplates)) { + $configSpec['page_templates'] = empty($configSpec['page_templates']) + ? $modulePageTemplates + : array_merge_recursive($configSpec['page_templates'], $modulePageTemplates); + } + if (count($moduleBlockTemplates)) { + $configSpec['block_templates'] = empty($configSpec['block_templates']) + ? $moduleBlockTemplates + : array_merge_recursive($configSpec['block_templates'], $moduleBlockTemplates); + } + $theme->setConfigSpec($configSpec); } // Note that, unlike the ModuleManagerFactory, this does not register