From: Roland Haeder Date: Tue, 24 Mar 2015 19:57:46 +0000 (+0100) Subject: Moved more methods to 'core' as they are now more generalized. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=142eae16bf8a30b39befdea555c4e467c7f07026;p=lfdb2.git Moved more methods to 'core' as they are now more generalized. Signed-off-by: Roland Haeder --- diff --git a/application/lfdb2/main/resolver/command/console/class_Lfdb2ConsoleCommandResolver.php b/application/lfdb2/main/resolver/command/console/class_Lfdb2ConsoleCommandResolver.php index c83fc7f..decf986 100644 --- a/application/lfdb2/main/resolver/command/console/class_Lfdb2ConsoleCommandResolver.php +++ b/application/lfdb2/main/resolver/command/console/class_Lfdb2ConsoleCommandResolver.php @@ -32,7 +32,7 @@ class Lfdb2ConsoleCommandResolver extends BaseCommandResolver implements Command parent::__construct(__CLASS__); // Set prefix to "Lfdb2Console" - $this->setClassPrefix('Lfdb2Console'); + $this->setClassPrefix('lfdb2_console'); } /** @@ -63,108 +63,6 @@ class Lfdb2ConsoleCommandResolver extends BaseCommandResolver implements Command // Return the prepared instance return $resolverInstance; } - - /** - * Returns an command instance for a given request class or null if - * it was not found - * - * @param $requestInstance An instance of a request class - * @return $commandInstance An instance of the resolved command - * @throws InvalidCommandException Thrown if $commandName is - * invalid - * @throws InvalidCommandInstanceException Thrown if $commandInstance - * is an invalid instance - */ - public function resolveCommandByRequest (Requestable $requestInstance) { - // Init variables - $commandName = ''; - $commandInstance = NULL; - - // This goes fine so let's resolve the command - $commandName = $requestInstance->getRequestElement('command'); - - // Is the command empty? Then fall back to default command - if (empty($commandName)) $commandName = $this->getConfigInstance()->getConfigEntry('default_console_command'); - - // Check if command is valid - if ($this->isCommandValid($commandName) === FALSE) { - // This command is invalid! - throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); - } // END - if - - // Get the command - $commandInstance = $this->loadCommand($commandName); - - // And validate it - if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) { - // This command has an invalid instance! - throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); - } // END - if - - // Set last command - $this->setResolvedInstance($commandInstance); - - // Return the resolved command instance - return $commandInstance; - } - - /** - * Resolves the command by its direct name and returns an instance of its class - * - * @param $commandName The direct command name we shall resolve - * @return $commandInstance An instance of the command class - * @throws InvalidCommandException Thrown if $commandName is invalid - */ - public function resolveCommand ($commandName) { - // Initiate the instance variable - $commandInstance = NULL; - - // Is the command empty? Then fall back to default command - if (empty($commandName)) $commandName = $this->getConfigInstance()->getConfigEntry('default_console_command'); - - // Check if command is valid - if ($this->isCommandValid($commandName) === FALSE) { - // This command is invalid! - throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); - } - - // Get the command - $commandInstance = $this->loadCommand($commandName); - - // Return the instance - return $commandInstance; - } - - /** - * "Loads" a given command and instances it if not yet cached - * - * @param $commandName A command name we shall look for - * @return $commandInstance A loaded command instance - * @throws InvalidCommandException Thrown if even the default - * command class is missing (bad!) - */ - private function loadCommand ($commandName) { - // Init command instance - $commandInstance = NULL; - - // Create class name - $className = 'Lfdb2Console' . $this->convertToClassName($commandName) . 'Command'; - - // Create command class name - $this->setClassName($className); - - // Is this class loaded? - if (!class_exists($this->getClassName())) { - // Class not found, so throw an exception - throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); - } // END - if - - // Initiate the command - $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this)); - - // Return the result - return $commandInstance; - } } // [EOF] diff --git a/core b/core index a142fe5..b84edaf 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit a142fe5eeaaa17a434c80ea103088558157c43bb +Subproject commit b84edaf9f45857dea7078c230cea0290089c0770