]> git.mxchange.org Git - mailer.git/blobdiff - inc/classes/main/resolver/controller/web/class_WebControllerResolver.php
Code merged from ship-simu repository
[mailer.git] / inc / classes / main / resolver / controller / web / class_WebControllerResolver.php
index da09dca315e5e2e3cde48a959fd50146c3801d0f..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
@@ -62,7 +62,7 @@ class WebControllerResolver extends BaseControllerResolver implements Controller
                if (empty($controllerName)) {
                        // Then thrown an exception here
                        throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!$resolverInstance->isControllerValid($controllerName)) {
+               } elseif ($resolverInstance->isControllerValid($controllerName) === false) {
                        // Invalid command found
                        throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
                }
@@ -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