$this->setObjectDescription("Resolver for local web controllers");
// Create unique ID number
- $this->createUniqueID();
+ $this->generateUniqueId();
// Set prefix to "Web"
$this->setCommandPrefix("Web");
}
/**
- * "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
$class = "WebDefaultController";
// Generate the class name
+ //* DEBUG: */ echo __METHOD__.": Command=".$commandName;
if ($commandName != $defaultCommand) {
// Create controller class name
$class = sprintf("Web%sController",
// No nes at "home" page
$class = "WebDefaultController";
}
+ //* DEBUG: */ echo ", controller=".$class."<br />\n";
// Is this class loaded?
if (!class_exists($class)) {
// Still not found?
throw new DefaultControllerException($this, self::EXCEPTION_DEFAUL_CONTROLLER_GONE);
}
- }
-
- // Initiate the controller
- $eval = sprintf("\$controllerInstance = %s::create%s(WebCommandResolver::createWebCommandResolver(\$commandName, \$this->getApplicationInstance()));",
- $class,
- $class
- );
+ } // END - if
- // Run the command
- eval($eval);
+ // Initiate the resolver and controller
+ $resolverInstance = ObjectFactory::createObjectByConfiguredName('web_cmd_resolver_class', array($commandName, $this->getApplicationInstance()));
+ $controllerInstance = ObjectFactory::createObjectByName($class, array($resolverInstance));
- // 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;