Response to feedback

This commit is contained in:
Damian Mooyman 2017-05-23 11:36:15 +12:00
parent fba8e2c245
commit d15b9ee0b0
7 changed files with 20 additions and 24 deletions

View File

@ -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);

View File

@ -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();

View File

@ -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);
}

View File

@ -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"

View File

@ -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)
);
}

View File

@ -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)) {

View File

@ -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);
}