*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
/**
* Last successfull resolved controller (name)
*/
- private $lastControllerName = "";
+ private $lastControllerName = '';
/**
* Last successfull resolved controller (instance)
*/
public function resolveController () {
// Init variables
- $controllerName = "";
+ $controllerName = '';
$controllerInstance = null;
// Get the command name
//* DEBUG: */ echo __METHOD__.": Controller=".$controllerName;
if ($controllerName != $defaultController) {
// Create controller class name
- $this->setClassName(sprintf("Web%sController",
- $this->convertToClassName($controllerName)
- ));
- } elseif ($this->getConfigInstance()->readConfig('page_with_news') == $this->getApplicationInstance()->getRequestInstance()->getRequestElement('page')) {
- // Yes, display news in home then set default controller with news
- $this->setClassName('WebDefaultNewsController');
+ $className = 'Web' . $this->convertToClassName($controllerName) . 'Controller';
+
+ // ... and set it
+ $this->setClassName($className);
} else {
// No news at home page or non-news page
$this->setClassName('WebDefaultController');
} // END - if
// Set default resolver config name
- $resolverConfigEntry = "";
+ $resolverConfigEntry = '';
// Try to read a config entry for our resolver including controller name... ;-)
try {
$resolverClass = $this->getConfigInstance()->readConfig($resolverConfigEntry);
} catch (ConfigEntryNotFoundException $e) {
// Use default resolver entry
- $resolverConfigEntry = "web_cmd_resolver_class";
+ // @TODO Maybe we need to log this?
+ $resolverConfigEntry = 'web_cmd_resolver_class';
}
// Initiate the resolver and controller
- $resolverInstance = ObjectFactory::createObjectByConfiguredName($resolverConfigEntry, array($controllerName, $this->getApplicationInstance()));
- $controllerInstance = ObjectFactory::createObjectByName($this->getClassName(), array($resolverInstance));
-
- // Remove resolver (we don't need it anymore)
- unset($resolverInstance);
+ $resolverInstance = ObjectFactory::createObjectByConfiguredName(
+ $resolverConfigEntry,
+ array(
+ $controllerName,
+ $this->getApplicationInstance()
+ )
+ );
+ $controllerInstance = ObjectFactory::createObjectByName(
+ $this->getClassName(),
+ array($resolverInstance)
+ );
// Return the result
return $controllerInstance;