From: Roland Haeder Date: Mon, 6 Apr 2015 22:40:10 +0000 (+0200) Subject: resolveController() was everywhere the same, still you can overwrite it with X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=80f58e52514b2fca93a2d37977a6874ece9b1e54;ds=sidebyside resolveController() was everywhere the same, still you can overwrite it with your own implementation. Signed-off-by: Roland Häder --- diff --git a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php index 14db8c3e..b9ae868f 100644 --- a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php +++ b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php @@ -141,6 +141,38 @@ class BaseControllerResolver extends BaseResolver { // Return the result return $isValid; } + + /** + * Resolves the default controller of the given command + * + * @return $controllerInstance A controller instance for the default + * command + * @throws InvalidControllerInstanceException Thrown if $controllerInstance + * is invalid + */ + public function resolveController () { + // Init variables + $controllerName = ''; + $controllerInstance = NULL; + + // Get the command name + $controllerName = $this->getControllerName(); + + // Get the command + $controllerInstance = $this->loadController($controllerName); + + // And validate it + if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { + // This command has an invalid instance! + throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } // END - if + + // Set last controller + $this->setResolvedInstance($controllerInstance); + + // Return the maybe resolved instance + return $controllerInstance; + } } // [EOF] diff --git a/inc/classes/main/resolver/controller/console/class_ConsoleControllerResolver.php b/inc/classes/main/resolver/controller/console/class_ConsoleControllerResolver.php index 4298385f..418a6e2a 100644 --- a/inc/classes/main/resolver/controller/console/class_ConsoleControllerResolver.php +++ b/inc/classes/main/resolver/controller/console/class_ConsoleControllerResolver.php @@ -66,38 +66,6 @@ class ConsoleControllerResolver extends BaseControllerResolver implements Contro // Return the prepared instance return $resolverInstance; } - - /** - * Resolves the default controller of the given command - * - * @return $controllerInstance A controller instance for the default - * command - * @throws InvalidControllerInstanceException Thrown if $controllerInstance - * is invalid - */ - public function resolveController () { - // Init variables - $controllerName = ''; - $controllerInstance = NULL; - - // Get the command name - $controllerName = $this->getControllerName(); - - // Get the command - $controllerInstance = $this->loadController($controllerName); - - // And validate it - if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { - // This command has an invalid instance! - throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } // END - if - - // Set last controller - $this->setResolvedInstance($controllerInstance); - - // Return the maybe resolved instance - return $controllerInstance; - } } // [EOF] diff --git a/inc/classes/main/resolver/controller/html/class_HtmlControllerResolver.php b/inc/classes/main/resolver/controller/html/class_HtmlControllerResolver.php index 8e05d454..20e101cf 100644 --- a/inc/classes/main/resolver/controller/html/class_HtmlControllerResolver.php +++ b/inc/classes/main/resolver/controller/html/class_HtmlControllerResolver.php @@ -66,38 +66,6 @@ class HtmlControllerResolver extends BaseControllerResolver implements Controlle // Return the prepared instance return $resolverInstance; } - - /** - * Resolves the default controller of the given command - * - * @return $controllerInstance A controller instance for the default - * command - * @throws InvalidControllerInstanceException Thrown if $controllerInstance - * is invalid - */ - public function resolveController () { - // Init variables - $controllerName = ''; - $controllerInstance = NULL; - - // Get the command name - $controllerName = $this->getControllerName(); - - // Get the command - $controllerInstance = $this->loadController($controllerName); - - // And validate it - if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { - // This command has an invalid instance! - throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } // END - if - - // Set last controller - $this->setResolvedInstance($controllerInstance); - - // Return the maybe resolved instance - return $controllerInstance; - } } // [EOF] diff --git a/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php b/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php index ef8ff23a..dde5f036 100644 --- a/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php +++ b/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php @@ -31,8 +31,8 @@ class ImageControllerResolver extends BaseControllerResolver implements Controll // Call parent constructor parent::__construct(__CLASS__); - // Set prefix to 'Image' - $this->setClassPrefix('8mage'); + // Set prefix to 'image' + $this->setClassPrefix('image'); } /** @@ -66,38 +66,6 @@ class ImageControllerResolver extends BaseControllerResolver implements Controll // Return the prepared instance return $resolverInstance; } - - /** - * Resolves the default controller of the given command - * - * @return $controllerInstance A controller instance for the default - * command - * @throws InvalidControllerInstanceException Thrown if $controllerInstance - * is invalid - */ - public function resolveController () { - // Init variables - $controllerName = ''; - $controllerInstance = NULL; - - // Get the command name - $controllerName = $this->getControllerName(); - - // Get the command - $controllerInstance = $this->loadController($controllerName); - - // And validate it - if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { - // This command has an invalid instance! - throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } // END - if - - // Set last controller - $this->setResolvedInstance($controllerInstance); - - // Return the maybe resolved instance - return $controllerInstance; - } } // [EOF]