]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/resolver/web/class_WebControllerResolver.php
Intercepting filter basicly added, generic form processor implemented (unfinished...
[shipsimu.git] / inc / classes / main / resolver / web / class_WebControllerResolver.php
index 16ad0c2c40dbbbcbfa2e7a46eeb7b352cbd6a97b..06d0bcfe57cdefdf7f0ddb2b61f38c3d9323175a 100644 (file)
  */
 class WebControllerResolver extends BaseResolver implements ControllerResolver {
        /**
-        * Last successfull resolved controller
+        * Last successfull resolved controller (name)
         */
        private $lastControllerName = "";
 
+       /**
+        * Last successfull resolved controller (instance)
+        */
+       private $lastControllerInstance = null;
+
        /**
         * Protected constructor
         *
@@ -114,8 +119,8 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
                                throw new InvalidControllerInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_CONTROLLER);
                        }
 
-                       // Set last command
-                       $this->lastCommandInstance = $controllerInstance;
+                       // Set last controller
+                       $this->lastControllerInstance = $controllerInstance;
                } catch (MissingArrayElementsException $e) {
                        // Just catch it here...
                }
@@ -133,6 +138,12 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
         *                                                                              controller class is missing (bad!)
         */
        private function loadController ($commandName) {
+                // Debug message
+                //print("<strong>----- ".__METHOD__." -----</strong><pre>");
+                //debug_print_backtrace();
+                //print("</pre>");
+                //
+
                // Cache default command
                $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
 
@@ -146,11 +157,14 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
                if ($commandName != $defaultCommand) {
                        // Create controller class name
                        $class = sprintf("Web%sController",
-                               ucfirst(strtolower($commandName))
+                               $this->convertToClassName($commandName)
                        );
                } elseif ($this->getConfigInstance()->readConfig("home_with_news") == "Y") {
                        // Yes, display news in home then set default controller with news
                        $class = "WebDefaultNewsController";
+               } else {
+                       // No nes at "home" page
+                       $class = "WebDefaultController";
                }
 
                // Is this class loaded?