Continued:
authorRoland Haeder <roland@mxchange.org>
Fri, 24 Feb 2017 21:10:34 +0000 (22:10 +0100)
committerRoland Haeder <roland@mxchange.org>
Tue, 28 Feb 2017 21:10:04 +0000 (22:10 +0100)
- no need to have namespace as parameter (only isValidFoo() calls) as it can be
  set in BaseResolver and all resolvers can use it which they must do anyway.
- added "import" for DefaultControllerException
- added "import" for Controller

Signed-off-by: Roland H├Ąder <roland@mxchange.org>
21 files changed:
application/tests/classes/controller/console/class_TestsConsoleDefaultNewsController.php
application/tests/classes/resolver/controller/class_TestsConsoleControllerResolver.php
application/tests/config.php
inc/main/classes/controller/console/class_ConsoleDefaultNewsController.php
inc/main/classes/controller/html/class_HtmlConfirmController.php
inc/main/classes/controller/html/class_HtmlDefaultController.php
inc/main/classes/controller/html/class_HtmlDefaultNewsController.php
inc/main/classes/controller/html/class_HtmlLoginController.php
inc/main/classes/controller/html/class_HtmlLoginFailedController.php
inc/main/classes/controller/html/class_HtmlLogoutController.php
inc/main/classes/controller/html/class_HtmlLogoutDoneController.php
inc/main/classes/controller/html/class_HtmlProblemController.php
inc/main/classes/controller/html/class_HtmlRegisterController.php
inc/main/classes/controller/html/class_HtmlStatusController.php
inc/main/classes/controller/html/form/class_HtmlDoFormController.php
inc/main/classes/controller/html/login/class_HtmlLoginAreaController.php
inc/main/classes/controller/image/captcha/class_ImageCodeCaptchaController.php
inc/main/classes/controller/image/class_ImageDefaultController.php
inc/main/classes/resolver/class_BaseResolver.php
inc/main/classes/resolver/controller/class_BaseControllerResolver.php
inc/main/interfaces/controller/class_Controller.php

index 2f6e415..266ee54 100644 (file)
@@ -4,6 +4,9 @@ namespace CoreFramework\Tests\Controller;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
+use CoreFramework\Request\Requestable;
+use CoreFramework\Response\Responseable;
 
 /**
  * The default controller with news for e.g. home or news page
index 3c9023f..f707e1f 100644 (file)
@@ -61,7 +61,7 @@ class TestsConsoleControllerResolver extends BaseControllerResolver implements C
                if (empty($controllerName)) {
                        // Then thrown an exception here
                        throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif ($resolverInstance->isControllerValid(__NAMESPACE__, $controllerName) === FALSE) {
+               } elseif ($resolverInstance->isControllerValid('CoreFramework\Tests\Controller', $controllerName) === FALSE) {
                        // Invalid command found
                        throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
                }
@@ -69,7 +69,8 @@ class TestsConsoleControllerResolver extends BaseControllerResolver implements C
                // Set the application instance
                $resolverInstance->setApplicationInstance($applicationInstance);
 
-               // Set command name
+               // Set namespace and controller name
+               $resolverInstance->setNamespace('CoreFramework\Tests\Controller');
                $resolverInstance->setControllerName($controllerName);
 
                // Return the prepared instance
@@ -89,7 +90,7 @@ class TestsConsoleControllerResolver extends BaseControllerResolver implements C
                $controllerName = '';
                $controllerInstance = NULL;
 
-               // Get the command name 
+               // Get namespace and command name
                $controllerName = $this->getControllerName();
 
                // Get the command
index 3ed7924..c965371 100644 (file)
@@ -28,7 +28,10 @@ use CoreFramework\Configuration\FrameworkConfiguration;
 $cfg = FrameworkConfiguration::getSelfInstance();
 
 // CFG: DEFAULT-CONSOLE-COMMAND
-$cfg->setConfigEntry('default_console_command', 'tests');
+$cfg->setConfigEntry('default_console_command', 'main');
 
 // CFG: DEFAULT-TESTS-CONSOLE-COMMAND
-$cfg->setConfigEntry('default_tests_console_command', 'tests');
+$cfg->setConfigEntry('default_tests_console_command', 'main');
+
+// CFG: DEFAULT-TESTS-CONSOLE-CONTROLLER
+$cfg->setConfigEntry('default_tests_console_controller', 'main');
index 2bcca95..c9b9e5d 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Default;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Factory\ObjectFactory;
 use CoreFramework\Request\Requestable;
 use CoreFramework\Response\Responseable;
index dcdfa84..d5477f6 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Confirm;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Factory\ObjectFactory;
 use CoreFramework\Response\Responseable;
 
index 5fbf4e3..6a10801 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Default;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Request\Requestable;
 use CoreFramework\Response\Responseable;
 
index 8a793bb..e659be7 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\News;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Factory\ObjectFactory;
 use CoreFramework\Response\Responseable;
 
index ddcfb2e..f6f9581 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Login;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Request\Requestable;
 use CoreFramework\Response\Responseable;
 
index a32264a..9d7b940 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Failed;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Request\Requestable;
 use CoreFramework\Response\Responseable;
 
index 8d96fb5..4650596 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Logout;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Factory\ObjectFactory;
 use CoreFramework\Request\Requestable;
 use CoreFramework\Response\Responseable;
index 4a2fa09..28460c4 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Logout;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Request\Requestable;
 
 /**
index de8bbf3..3cb8143 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Problem;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Request\Requestable;
 use CoreFramework\Response\Responseable;
 
index e6214f6..5357ced 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Register;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Response\Responseable;
 
 /**
index 59e13bd..83dbe64 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Status;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Request\Requestable;
 use CoreFramework\Response\Responseable;
 
index d71343b..379300c 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Form;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Request\Requestable;
 use CoreFramework\Response\Responseable;
 
index 7b4c5d8..0b4608a 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Login;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Factory\ObjectFactory;
 use CoreFramework\Request\Requestable;
 use CoreFramework\Response\Responseable;
index a8144ce..165dfd7 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Image\Captcha;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Factory\ObjectFactory;
 use CoreFramework\Request\Requestable;
 use CoreFramework\Response\Responseable;
index 37424f9..c1e22b8 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Controller\Default;
 
 // Import framework stuff
 use CoreFramework\Controller\BaseController;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Request\Requestable;
 use CoreFramework\Response\Responseable;
 
index 395cc86..ddbf41d 100644 (file)
@@ -30,6 +30,11 @@ use CoreFramework\Object\BaseFrameworkSystem;
  */
 class BaseResolver extends BaseFrameworkSystem {
        /**
+        * Namespace
+        */
+       private $namespace = '';
+
+       /**
         * Class name
         */
        private $className = '';
@@ -62,6 +67,25 @@ class BaseResolver extends BaseFrameworkSystem {
        }
 
        /**
+        * Getter for namespace
+        *
+        * @return      $namespace      Namespace to look in
+        */
+       public final function getNamespace () {
+               return $this->namespace;
+       }
+
+       /**
+        * Setter for namespace
+        *
+        * @param       $namespace      Namespace to look in
+        * @return      void
+        */
+       protected final function setNamespace ($namespace) {
+               $this->namespace = (string) $namespace;
+       }
+
+       /**
         * Getter for class name
         *
         * @return      $className      Name of the class
@@ -71,6 +95,16 @@ class BaseResolver extends BaseFrameworkSystem {
        }
 
        /**
+        * Setter for class name
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected final function setClassName ($className) {
+               $this->className = (string) $className;
+       }
+
+       /**
         * "Getter" for class name (useable for an object factory)
         *
         * @return      $className      Capitalized class name
@@ -87,16 +121,6 @@ class BaseResolver extends BaseFrameworkSystem {
        }
 
        /**
-        * Setter for class name
-        *
-        * @param       $className      Name of the class
-        * @return      void
-        */
-       protected final function setClassName ($className) {
-               $this->className = (string) $className;
-       }
-
-       /**
         * Getter for class prefix
         *
         * @return      $classPrefix    Last validated classPrefix
index fdcf6af..3d31889 100644 (file)
@@ -3,10 +3,11 @@
 namespace CoreFramework\Resolver\Controller;
 
 // Import framework stuff
+use CoreFramework\Controller\DefaultControllerException;
+use CoreFramework\Controller\Generic\Controller;
 use CoreFramework\Factory\ObjectFactory;
 use CoreFramework\Resolver\BaseResolver;
 use CoreFramework\Resolver\Controller\ControllerResolver;
-
 /**
  * A generic controller resolver class
  *
@@ -46,13 +47,12 @@ class BaseControllerResolver extends BaseResolver {
         * controller was not found one of the default controllers will be used
         * depending on whether news shall be displayed.
         *
-        * @param       $namespace                              Namespace to look in
         * @param       $controllerName                 A controller name we shall look for
         * @return      $controllerInstance             A loaded controller instance
         * @throws      InvalidControllerException      Thrown if even the requested
         *                                                                              controller class is missing (bad!)
         */
-       protected function loadController ($namespace, $controllerName) {
+       protected function loadController ($controllerName) {
                // Cache default controller
                $defaultController = $this->getConfigInstance()->getConfigEntry('default_' . strtolower($this->getClassPrefix()) . '_controller');
 
@@ -62,7 +62,7 @@ class BaseControllerResolver extends BaseResolver {
                // Create full class name
                $className = sprintf(
                        '%s\%sDefaultNewsController',
-                       $namespace,
+                       $this->getNamespace(),
                        $this->getCapitalizedClassPrefix()
                );
 
@@ -150,7 +150,7 @@ class BaseControllerResolver extends BaseResolver {
                );
 
                // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('className=%s', $className));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('className=%s', $className));
 
                // Now, let us create the full name of the controller class
                $this->setClassName($className);
@@ -188,11 +188,10 @@ class BaseControllerResolver extends BaseResolver {
                $controllerInstance = NULL;
 
                // Get namespace and controller name
-               $namespace      = $this->getNamespace();
                $controllerName = $this->getControllerName();
 
                // Get the controller
-               $controllerInstance = $this->loadController($namspace, $controllerName);
+               $controllerInstance = $this->loadController($controllerName);
 
                // And validate it
                if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
index 0a2d52c..e5a8945 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Controller;
+namespace CoreFramework\Controller\Generic;
 
 // Import framework stuff
 use CoreFramework\Generic\FrameworkInterface;