From d1d4c27a298fb48a433ab3ee132229d88274b060 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 4 Nov 2020 14:24:29 +0100 Subject: [PATCH] Continued: - also include namespace here, may break code! MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../command/console/class_ConsoleCommandResolver.php | 10 +++++++--- .../controller/class_BaseControllerResolver.php | 4 +--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/framework/main/classes/resolver/command/console/class_ConsoleCommandResolver.php b/framework/main/classes/resolver/command/console/class_ConsoleCommandResolver.php index ae85aa7e..7cd5109e 100644 --- a/framework/main/classes/resolver/command/console/class_ConsoleCommandResolver.php +++ b/framework/main/classes/resolver/command/console/class_ConsoleCommandResolver.php @@ -49,20 +49,24 @@ class ConsoleCommandResolver extends BaseCommandResolver implements CommandResol /** * Creates an instance of a Console command resolver with a given default command * + * @param $namespace Namespace of the command's class file * @param $commandName The default command we shall execute * @return $resolverInstance The prepared command resolver instance * @throws InvalidArgumentException Thrown if default command is not set * @throws InvalidCommandException Thrown if default command is invalid */ - public static final function createConsoleCommandResolver ($commandName) { + public static final function createConsoleCommandResolver ($namespace, $commandName) { // Create the new instance $resolverInstance = new ConsoleCommandResolver(); // Is the variable $commandName set and the command is valid? - if (empty($commandName)) { + if (empty($namespace)) { + // Then thrown an exception here + throw new InvalidArgumentException('Parameter "namespace" is empty'); + } elseif (empty($commandName)) { // Then thrown an exception here throw new InvalidArgumentException('Parameter "commandName" is empty'); - } elseif ($resolverInstance->isCommandValid($commandName) === false) { + } elseif (!$resolverInstance->isCommandValid($namespace, $commandName)) { // Invalid command found throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); } diff --git a/framework/main/classes/resolver/controller/class_BaseControllerResolver.php b/framework/main/classes/resolver/controller/class_BaseControllerResolver.php index 216aa11f..c47e4df2 100644 --- a/framework/main/classes/resolver/controller/class_BaseControllerResolver.php +++ b/framework/main/classes/resolver/controller/class_BaseControllerResolver.php @@ -100,13 +100,11 @@ abstract class BaseControllerResolver extends BaseResolver { throw new InvalidControllerException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); } // END - if - // Set default resolver config name - $resolverConfigEntry = ''; - // Try to read a config entry for our resolver including controller name... ;-) $resolverConfigEntry = sprintf('%s_cmd_%s_resolver_class', strtolower($this->getClassPrefix()), strtolower($controllerName)); // Get the config, this will throw an exception if there is no special controller resolver + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-CONTROLLER-RESOLVER: resolverConfigEntry=%s', $resolverConfigEntry)); $resolverClass = $this->getConfigInstance()->getConfigEntry($resolverConfigEntry); // Initiate the resolver and controller -- 2.39.2