]> git.mxchange.org Git - hub.git/blobdiff - inc/classes/main/resolver/web/class_WebControllerResolver.php
Code syncronized with shipsimu code base
[hub.git] / inc / classes / main / resolver / web / class_WebControllerResolver.php
index 9e50d94516dfe8a99b592f7a8a73b33257257eaa..60dfcfe0f5271e3a3dd6d1c7c09c05bdfc5fd1aa 100644 (file)
@@ -41,12 +41,6 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
                // Call parent constructor
                parent::__construct(__CLASS__);
 
-               // Set part description
-               $this->setObjectDescription("Resolver for local web controllers");
-
-               // Create unique ID number
-               $this->createUniqueID();
-
                // Set prefix to "Web"
                $this->setCommandPrefix("Web");
        }
@@ -126,7 +120,9 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
        }
 
        /**
-        * "Loads" a given controller and instances it if not yet cached
+        * "Loads" a given controller and instances it if not yet cached. If the
+        * controller was not found one of the default controllers will be used
+        * depending on wether news shall be displayed.
         *
         * @param       $commandName                    A controller name we shall look for
         * @return      $controllerInstance             A loaded controller instance
@@ -150,6 +146,7 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
                $class = "WebDefaultController";
 
                // Generate the class name
+               //* DEBUG: */ echo __METHOD__.": Command=".$commandName;
                if ($commandName != $defaultCommand) {
                        // Create controller class name
                        $class = sprintf("Web%sController",
@@ -162,6 +159,7 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
                        // No nes at "home" page
                        $class = "WebDefaultController";
                }
+               //* DEBUG: */ echo ", controller=".$class."<br />\n";
 
                // Is this class loaded?
                if (!class_exists($class)) {
@@ -173,22 +171,14 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
                                // Still not found?
                                throw new DefaultControllerException($this, self::EXCEPTION_DEFAUL_CONTROLLER_GONE);
                        }
-               }
+               } // END - if
 
-               // Initiate the controller
-               $eval = sprintf("\$controllerInstance = %s::create%s(WebCommandResolver::createWebCommandResolver(\$commandName, \$this->getApplicationInstance()));",
-                       $class,
-                       $class
-               );
+               // Initiate the resolver and controller
+               $resolverInstance = ObjectFactory::createObjectByConfiguredName('web_cmd_resolver_class', array($commandName, $this->getApplicationInstance()));
+               $controllerInstance = ObjectFactory::createObjectByName($class, array($resolverInstance));
 
-               // Run the command
-               eval($eval);
-
-               // Is the instance valid?
-               if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
-                       // Something is wrong
-                       $controllerInstance = null;
-               }
+               // Remove resolver
+               unset($resolverInstance);
 
                // Return the result
                return $controllerInstance;