MINOR: Allow DevelopmentAdmin to have subclasses (#9702)

This commit is contained in:
Aaron Carlino 2020-09-26 21:21:16 +12:00 committed by GitHub
parent d6cb539335
commit 2042d1c6b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -130,7 +130,7 @@ class DevelopmentAdmin extends Controller
$controllerClass = null; $controllerClass = null;
$baseUrlPart = $request->param('Action'); $baseUrlPart = $request->param('Action');
$reg = Config::inst()->get(__CLASS__, 'registered_controllers'); $reg = Config::inst()->get(static::class, 'registered_controllers');
if (isset($reg[$baseUrlPart])) { if (isset($reg[$baseUrlPart])) {
$controllerClass = $reg[$baseUrlPart]['controller']; $controllerClass = $reg[$baseUrlPart]['controller'];
} }
@ -139,7 +139,7 @@ class DevelopmentAdmin extends Controller
return $controllerClass::create(); return $controllerClass::create();
} }
$msg = 'Error: no controller registered in ' . __CLASS__ . ' for: ' . $request->param('Action'); $msg = 'Error: no controller registered in ' . static::class . ' for: ' . $request->param('Action');
if (Director::is_cli()) { if (Director::is_cli()) {
// in CLI we cant use httpError because of a bug with stuff being in the output already, see DevAdminControllerTest // in CLI we cant use httpError because of a bug with stuff being in the output already, see DevAdminControllerTest
throw new Exception($msg); throw new Exception($msg);
@ -162,7 +162,7 @@ class DevelopmentAdmin extends Controller
{ {
$links = []; $links = [];
$reg = Config::inst()->get(__CLASS__, 'registered_controllers'); $reg = Config::inst()->get(static::class, 'registered_controllers');
foreach ($reg as $registeredController) { foreach ($reg as $registeredController) {
if (isset($registeredController['links'])) { if (isset($registeredController['links'])) {
foreach ($registeredController['links'] as $url => $desc) { foreach ($registeredController['links'] as $url => $desc) {
@ -175,7 +175,7 @@ class DevelopmentAdmin extends Controller
protected function getRegisteredController($baseUrlPart) protected function getRegisteredController($baseUrlPart)
{ {
$reg = Config::inst()->get(__CLASS__, 'registered_controllers'); $reg = Config::inst()->get(static::class, 'registered_controllers');
if (isset($reg[$baseUrlPart])) { if (isset($reg[$baseUrlPart])) {
$controllerClass = $reg[$baseUrlPart]['controller']; $controllerClass = $reg[$baseUrlPart]['controller'];