Typos fixed and special command resolver are now possible
[shipsimu.git] / inc / classes / main / resolver / controller / web / class_WebControllerResolver.php
index 22933936c49252118fce86f5aa8c3da1ec18da11..5378006099a8c964f98d01ab13826f24133866bb 100644 (file)
@@ -51,8 +51,8 @@ class WebControllerResolver extends BaseControllerResolver implements Controller
         * @param       $controllerName                         The controller we shall resolve
         * @param       $appInstance                            An instance of a manageable application helper class
         * @return      $resolverInstance                       The prepared controller resolver instance
-        * @throws      EmptyVariableException          Thrown if the default command is not set
-        * @throws      InvalidControllerException      Thrown if the default controller is invalid
+        * @throws      EmptyVariableException          Thrown if default command is not set
+        * @throws      InvalidControllerException      Thrown if default controller is invalid
         */
        public final static function createWebControllerResolver ($controllerName, ManageableApplication $appInstance) {
                // Create the new instance
@@ -151,11 +151,26 @@ class WebControllerResolver extends BaseControllerResolver implements Controller
                        throw new InvalidControllerException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
                } // END - if
 
+               // Set default resolver config name
+               $resolverConfigEntry = "";
+
+               // Try to read a config entry for our resolver including controller name... ;-)
+               try {
+                       // Create the resolver name
+                       $resolverConfigEntry = sprintf("web_cmd_%s_resolver_class", strtolower($controllerName));
+
+                       // Get the config, this will throw an exception if there is no special command resolver
+                       $resolverClass = $this->getConfigInstance()->readConfig($resolverConfigEntry);
+               } catch (ConfigEntryNotFoundException $e) {
+                       // Use default resolver entry
+                       $resolverConfigEntry = "web_cmd_resolver_class";
+               }
+
                // Initiate the resolver and controller
-               $resolverInstance = ObjectFactory::createObjectByConfiguredName('web_cmd_resolver_class', array($controllerName, $this->getApplicationInstance()));
+               $resolverInstance = ObjectFactory::createObjectByConfiguredName($resolverConfigEntry, array($controllerName, $this->getApplicationInstance()));
                $controllerInstance = ObjectFactory::createObjectByName($this->getClassName(), array($resolverInstance));
 
-               // Remove resolver
+               // Remove resolver (we don't need it anymore)
                unset($resolverInstance);
 
                // Return the result