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) {
|
||||
$templates = $this->template;
|
||||
} else {
|
||||
// Add action-specific templates for inheritance chain
|
||||
$templates = array();
|
||||
// Build templates based on class hierarchy
|
||||
$actionTemplates = [];
|
||||
$classTemplates = [];
|
||||
$parentClass = static::class;
|
||||
while ($parentClass !== parent::class) {
|
||||
// _action templates have higher priority
|
||||
if ($action && $action != 'index') {
|
||||
$parentClass = static::class;
|
||||
while ($parentClass != __CLASS__) {
|
||||
$templates[] = strtok($parentClass, '_') . '_' . $action;
|
||||
$actionTemplates[] = strtok($parentClass, '_') . '_' . $action;
|
||||
}
|
||||
// class templates have lower priority
|
||||
$classTemplates[] = strtok($parentClass, '_');
|
||||
$parentClass = get_parent_class($parentClass);
|
||||
}
|
||||
}
|
||||
|
||||
// Add controller templates for inheritance chain
|
||||
$parentClass = static::class;
|
||||
while ($parentClass != __CLASS__) {
|
||||
$templates[] = strtok($parentClass, '_');
|
||||
$parentClass = get_parent_class($parentClass);
|
||||
}
|
||||
|
||||
$templates[] = __CLASS__;
|
||||
|
||||
// remove duplicates
|
||||
$templates = array_unique($templates);
|
||||
$templates = array_unique(array_merge($actionTemplates, $classTemplates));
|
||||
}
|
||||
|
||||
return new SSViewer($templates);
|
||||
|
@ -84,7 +84,7 @@ class FunctionalTest extends SapphireTest
|
||||
{
|
||||
// Skip calling FunctionalTest directly.
|
||||
if (static::class == __CLASS__) {
|
||||
$this->markTestSkipped(sprintf('Skipping %s ', get_class($this)));
|
||||
$this->markTestSkipped(sprintf('Skipping %s ', static::class));
|
||||
}
|
||||
|
||||
parent::setUp();
|
||||
|
@ -244,7 +244,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
// We cannot run the tests on this abstract class.
|
||||
if (static::class == __CLASS__) {
|
||||
$this->markTestSkipped(sprintf('Skipping %s ', get_class($this)));
|
||||
$this->markTestSkipped(sprintf('Skipping %s ', static::class));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -563,9 +563,9 @@ class SapphireTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
protected function getCurrentAbsolutePath()
|
||||
{
|
||||
$filename = self::$test_class_manifest->getItemPath(get_class($this));
|
||||
$filename = self::$test_class_manifest->getItemPath(static::class);
|
||||
if (!$filename) {
|
||||
throw new LogicException("getItemPath returned null for " . get_class($this));
|
||||
throw new LogicException("getItemPath returned null for " . static::class);
|
||||
}
|
||||
return dirname($filename);
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ class CompositeField extends FormField
|
||||
$formName = (isset($this->form)) ? $this->form->FormName() : '(unknown form)';
|
||||
if (isset($list[$name])) {
|
||||
$fieldClass = get_class($field);
|
||||
$otherFieldClass = $list[$name]->class;
|
||||
$otherFieldClass = get_class($list[$name]);
|
||||
user_error(
|
||||
"collateDataFields() I noticed that a field called '$name' appears twice in"
|
||||
. " your form: '{$formName}'. One is a '{$fieldClass}' and the other is a"
|
||||
|
@ -213,7 +213,7 @@ class FormRequestHandler extends RequestHandler
|
||||
) {
|
||||
return $this->httpError(
|
||||
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
|
||||
$tableOptionsChanged = false;
|
||||
// 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;
|
||||
if ($dbID && isset($options[$dbID])) {
|
||||
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);
|
||||
/** @var HasManyList $result */
|
||||
if ($polymorphic) {
|
||||
$result = PolymorphicHasManyList::create($componentClass, $joinField, get_class($this));
|
||||
$result = PolymorphicHasManyList::create($componentClass, $joinField, static::class);
|
||||
} else {
|
||||
$result = HasManyList::create($componentClass, $joinField);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user