mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Compare commits
2 Commits
1d46b724c9
...
326e8732ea
Author | SHA1 | Date | |
---|---|---|---|
|
326e8732ea | ||
|
1a5eab0eb1 |
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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() ?? ''));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user