Compare commits

..

2 Commits

Author SHA1 Message Date
Guy Sartorelli
326e8732ea
Merge 1a5eab0eb1 into bd48b04731 2024-10-10 00:28:39 +00:00
Guy Sartorelli
1a5eab0eb1
ENH Improve type safety to support refactored template layer 2024-10-10 13:28:30 +13:00
3 changed files with 8 additions and 8 deletions

View File

@ -405,20 +405,20 @@ HTML;
$action = $action === 'index' ? '' : '_' . $action;
$templatesFound = [];
// Find templates for the record + action together - e.g. Page_action
// Find templates for the record + action together - e.g. Page_action.ss
if ($this->dataRecord instanceof SiteTree) {
$templatesFound[] = $this->dataRecord->getViewerTemplates($action);
}
// Find templates for the controller + action together - e.g. PageController_action
// Find templates for the controller + action together - e.g. PageController_action.ss
$templatesFound[] = SSViewer::get_templates_by_class(static::class, $action ?? '', Controller::class);
// Find templates for the record without an action - e.g. Page
// Find templates for the record without an action - e.g. Page.ss
if ($this->dataRecord instanceof SiteTree) {
$templatesFound[] = $this->dataRecord->getViewerTemplates();
}
// Find the templates for the controller without an action - e.g. PageController
// Find the templates for the controller without an action - e.g. PageController.ss
$templatesFound[] = SSViewer::get_templates_by_class(static::class, '', Controller::class);
$templates = array_merge(...$templatesFound);

View File

@ -33,7 +33,7 @@ class ThemeContext implements Context
}
/**
* Create a template within a test theme. Only ss templates are supported.
* Create a template within a test theme
*
* @Given /^a template "(?<template>[^"]+)" in theme "(?<theme>[^"]+)" with content "(?<content>[^"]+)"/
* @param string $template

View File

@ -164,7 +164,7 @@ class ContentControllerTest extends FunctionalTest
{
$this->useTestTheme(__DIR__, 'controllertest', function () {
// Test a page without a controller (ContentControllerTest_PageWithoutController)
// Test a page without a controller (ContentControllerTest_PageWithoutController.ss)
$page = new ContentControllerTestPageWithoutController();
$page->URLSegment = "test";
$page->write();
@ -173,7 +173,7 @@ class ContentControllerTest extends FunctionalTest
$response = $this->get($page->RelativeLink());
$this->assertEquals("ContentControllerTestPageWithoutController", trim($response->getBody() ?? ''));
// This should fall over to use Page
// This should fall over to user Page.ss
$page = new ContentControllerTestPage();
$page->URLSegment = "test";
$page->write();
@ -193,7 +193,7 @@ class ContentControllerTest extends FunctionalTest
$this->assertEquals("ContentControllerTestPage_test", trim($response->getBody() ?? ''));
// Test that an action without a template will default to the index template, which is
// to say the default Page template
// to say the default Page.ss template
$response = $this->get($page->RelativeLink("testwithouttemplate"));
$this->assertEquals("Page", trim($response->getBody() ?? ''));