FIX Template discovery on themed Layout templates

Was failing when 'main' template only exists in theme,
but 'Layout' template only exists in module.
This commit is contained in:
Ingo Schommer 2013-04-29 17:19:51 +02:00
parent cef955c8b9
commit 5efae23cb2
6 changed files with 21 additions and 7 deletions

View File

@ -115,11 +115,11 @@ class SS_TemplateManifest {
if ($this->project && isset($candidates[$this->project])) {
$found = $candidates[$this->project];
} else if ($theme && isset($candidates['themes'][$theme])) {
$found = $candidates['themes'][$theme];
$found = array_merge($candidates, $candidates['themes'][$theme]);
} else {
unset($candidates['themes']);
$found = $candidates;
}
if(isset($found['themes'])) unset($found['themes']);
return $found;
}

View File

@ -42,6 +42,13 @@ class TemplateLoaderTest extends SapphireTest {
);
$this->assertEquals($expectCustomPage, $loader->findTemplates(array('CustomPage', 'Page')));
// 'main' template only exists in theme, and 'Layout' template only exists in module
$expectCustomThemePage = array(
'main' => "$base/themes/theme/templates/CustomThemePage.ss",
'Layout' => "$base/module/templates/Layout/CustomThemePage.ss"
);
$this->assertEquals($expectCustomThemePage, $loader->findTemplates(array('CustomThemePage', 'Page'), 'theme'));
}
public function testFindTemplatesApplicationOverridesModule() {

View File

@ -47,6 +47,13 @@ class TemplateManifestTest extends SapphireTest {
'subfolder' => array(
'main' => "{$this->base}/module/subfolder/templates/Subfolder.ss"
),
'customthemepage' => array (
'Layout' => "{$this->base}/module/templates/Layout/CustomThemePage.ss",
'themes' =>
array(
'theme' => array('main' => "{$this->base}/themes/theme/templates/CustomThemePage.ss",)
)
),
'include' => array('themes' => array(
'theme' => array(
'Includes' => "{$this->base}/themes/theme/templates/Includes/Include.ss"