From 9eb703e65f6334b24852c14b34649e78c812d3ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 22 Nov 2020 17:53:01 +0100 Subject: [PATCH] Continued: - fixed resolving order: 1) application's controller will be checked 2) the application "tests" need its own default news controller 3) else load framework's default news controller MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../class_BaseControllerResolver.php | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/framework/main/classes/resolver/controller/class_BaseControllerResolver.php b/framework/main/classes/resolver/controller/class_BaseControllerResolver.php index ddad2563..2ff9ee36 100644 --- a/framework/main/classes/resolver/controller/class_BaseControllerResolver.php +++ b/framework/main/classes/resolver/controller/class_BaseControllerResolver.php @@ -178,16 +178,20 @@ abstract class BaseControllerResolver extends BaseResolver { $namespace, $this->getCapitalizedClassPrefix() . StringUtils::convertToClassName($controllerName) ); - $newsControllerName = sprintf( + // Application's default news controller + $appDefaultControllerName = sprintf( '%s\%sDefaultNewsController', $namespace, $this->getCapitalizedClassPrefix() ); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('className=%s', $className)); + // Framework's default news controller + $defaultControllerName = sprintf( + 'Org\Mxchange\CoreFramework\Controller\News\%sDefaultNewsController', + $this->getCapitalizedClassPrefix() + ); // Now, let us create the full name of the controller class + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('className=%s', $className)); $this->setClassName($className); // Try it hard to get an controller @@ -196,14 +200,17 @@ abstract class BaseControllerResolver extends BaseResolver { if (class_exists($this->getClassName())) { // This class does exist. :-) $isValid = true; - } elseif ($this->getClassName() != $newsControllerName) { - // Set default controller - $this->setClassName($newsControllerName); + } elseif ($this->getClassName() != $appDefaultControllerName) { + // Set application's default controller + $this->setClassName($appDefaultControllerName); + } elseif ($this->getClassName() != $defaultControllerName) { + // Set framework's default controller + $this->setClassName($defaultControllerName); } else { // All is tried, give it up here throw new DefaultControllerException($this, self::EXCEPTION_DEFAULT_CONTROLLER_GONE); } - } // END - while + } // Return the result return $isValid; -- 2.39.2