mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Response to feedback
This commit is contained in:
parent
fba8e2c245
commit
d15b9ee0b0
@ -400,26 +400,22 @@ class Controller extends RequestHandler implements TemplateGlobalProvider
|
|||||||
} elseif ($this->template) {
|
} elseif ($this->template) {
|
||||||
$templates = $this->template;
|
$templates = $this->template;
|
||||||
} else {
|
} else {
|
||||||
// Add action-specific templates for inheritance chain
|
// Build templates based on class hierarchy
|
||||||
$templates = array();
|
$actionTemplates = [];
|
||||||
|
$classTemplates = [];
|
||||||
|
$parentClass = static::class;
|
||||||
|
while ($parentClass !== parent::class) {
|
||||||
|
// _action templates have higher priority
|
||||||
if ($action && $action != 'index') {
|
if ($action && $action != 'index') {
|
||||||
$parentClass = static::class;
|
$actionTemplates[] = strtok($parentClass, '_') . '_' . $action;
|
||||||
while ($parentClass != __CLASS__) {
|
}
|
||||||
$templates[] = strtok($parentClass, '_') . '_' . $action;
|
// class templates have lower priority
|
||||||
|
$classTemplates[] = strtok($parentClass, '_');
|
||||||
$parentClass = get_parent_class($parentClass);
|
$parentClass = get_parent_class($parentClass);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Add controller templates for inheritance chain
|
// Add controller templates for inheritance chain
|
||||||
$parentClass = static::class;
|
$templates = array_unique(array_merge($actionTemplates, $classTemplates));
|
||||||
while ($parentClass != __CLASS__) {
|
|
||||||
$templates[] = strtok($parentClass, '_');
|
|
||||||
$parentClass = get_parent_class($parentClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
$templates[] = __CLASS__;
|
|
||||||
|
|
||||||
// remove duplicates
|
|
||||||
$templates = array_unique($templates);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SSViewer($templates);
|
return new SSViewer($templates);
|
||||||
|
@ -84,7 +84,7 @@ class FunctionalTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
// Skip calling FunctionalTest directly.
|
// Skip calling FunctionalTest directly.
|
||||||
if (static::class == __CLASS__) {
|
if (static::class == __CLASS__) {
|
||||||
$this->markTestSkipped(sprintf('Skipping %s ', get_class($this)));
|
$this->markTestSkipped(sprintf('Skipping %s ', static::class));
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@ -244,7 +244,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
// We cannot run the tests on this abstract class.
|
// We cannot run the tests on this abstract class.
|
||||||
if (static::class == __CLASS__) {
|
if (static::class == __CLASS__) {
|
||||||
$this->markTestSkipped(sprintf('Skipping %s ', get_class($this)));
|
$this->markTestSkipped(sprintf('Skipping %s ', static::class));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,9 +563,9 @@ class SapphireTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
protected function getCurrentAbsolutePath()
|
protected function getCurrentAbsolutePath()
|
||||||
{
|
{
|
||||||
$filename = self::$test_class_manifest->getItemPath(get_class($this));
|
$filename = self::$test_class_manifest->getItemPath(static::class);
|
||||||
if (!$filename) {
|
if (!$filename) {
|
||||||
throw new LogicException("getItemPath returned null for " . get_class($this));
|
throw new LogicException("getItemPath returned null for " . static::class);
|
||||||
}
|
}
|
||||||
return dirname($filename);
|
return dirname($filename);
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ class CompositeField extends FormField
|
|||||||
$formName = (isset($this->form)) ? $this->form->FormName() : '(unknown form)';
|
$formName = (isset($this->form)) ? $this->form->FormName() : '(unknown form)';
|
||||||
if (isset($list[$name])) {
|
if (isset($list[$name])) {
|
||||||
$fieldClass = get_class($field);
|
$fieldClass = get_class($field);
|
||||||
$otherFieldClass = $list[$name]->class;
|
$otherFieldClass = get_class($list[$name]);
|
||||||
user_error(
|
user_error(
|
||||||
"collateDataFields() I noticed that a field called '$name' appears twice in"
|
"collateDataFields() I noticed that a field called '$name' appears twice in"
|
||||||
. " your form: '{$formName}'. One is a '{$fieldClass}' and the other is a"
|
. " your form: '{$formName}'. One is a '{$fieldClass}' and the other is a"
|
||||||
|
@ -213,7 +213,7 @@ class FormRequestHandler extends RequestHandler
|
|||||||
) {
|
) {
|
||||||
return $this->httpError(
|
return $this->httpError(
|
||||||
403,
|
403,
|
||||||
sprintf('Action "%s" not allowed on form request handler (Class: "%s")', $funcName, get_class($this))
|
sprintf('Action "%s" not allowed on form request handler (Class: "%s")', $funcName, static::class)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ abstract class DBSchemaManager
|
|||||||
// Check if options changed
|
// Check if options changed
|
||||||
$tableOptionsChanged = false;
|
$tableOptionsChanged = false;
|
||||||
// Check for DB constant on the schema class
|
// Check for DB constant on the schema class
|
||||||
$dbIDName = sprintf('%s::ID', get_class($this));
|
$dbIDName = sprintf('%s::ID', static::class);
|
||||||
$dbID = defined($dbIDName) ? constant($dbIDName) : null;
|
$dbID = defined($dbIDName) ? constant($dbIDName) : null;
|
||||||
if ($dbID && isset($options[$dbID])) {
|
if ($dbID && isset($options[$dbID])) {
|
||||||
if (preg_match('/ENGINE=([^\s]*)/', $options[$dbID], $alteredEngineMatches)) {
|
if (preg_match('/ENGINE=([^\s]*)/', $options[$dbID], $alteredEngineMatches)) {
|
||||||
|
@ -1596,7 +1596,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
$joinField = $schema->getRemoteJoinField(static::class, $componentName, 'has_many', $polymorphic);
|
$joinField = $schema->getRemoteJoinField(static::class, $componentName, 'has_many', $polymorphic);
|
||||||
/** @var HasManyList $result */
|
/** @var HasManyList $result */
|
||||||
if ($polymorphic) {
|
if ($polymorphic) {
|
||||||
$result = PolymorphicHasManyList::create($componentClass, $joinField, get_class($this));
|
$result = PolymorphicHasManyList::create($componentClass, $joinField, static::class);
|
||||||
} else {
|
} else {
|
||||||
$result = HasManyList::create($componentClass, $joinField);
|
$result = HasManyList::create($componentClass, $joinField);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user