X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fresolver%2Fcontroller%2Fweb%2Fclass_WebControllerResolver.php;h=5378006099a8c964f98d01ab13826f24133866bb;hb=5bf79580029c4f6ee71e6c9e7890169e4b344def;hp=22933936c49252118fce86f5aa8c3da1ec18da11;hpb=fc50e3805a154eca3330aeae911cd6b75c967e9f;p=shipsimu.git diff --git a/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php b/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php index 2293393..5378006 100644 --- a/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php +++ b/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php @@ -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