*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class BaseControllerResolver extends BaseResolver {
- /**
- * Prefix for local, remote or other resolver
- */
- private $controllerPrefix = '';
-
/**
* Validated controller name
*/
parent::__construct($className);
}
- /**
- * Setter for controller prefix
- *
- * @param $controllerPrefix Last validated controllerPrefix
- * @return void
- */
- protected final function setControllerPrefix ($controllerPrefix) {
- $this->controllerPrefix = $controllerPrefix;
- }
-
- /**
- * Getter for controller prefix
- *
- * @param $controllerPrefix Last validated controllerPrefix
- * @return void
- */
- protected final function getControllerPrefix () {
- return $this->controllerPrefix;
- }
-
/**
* Setter for controller name
*
*/
protected function loadController ($controllerName) {
// Cache default command
- $defaultController = $this->getConfigInstance()->readConfig('default_' . strtolower($this->getControllerPrefix()) . '_command');
+ $defaultController = $this->getConfigInstance()->getConfigEntry('default_' . strtolower($this->getClassPrefix()) . '_command');
// Init controller instance
$controllerInstance = null;
// Default controller
- $this->setClassName($this->getControllerPrefix() . 'DefaultNewsController');
+ $this->setClassName($this->getClassPrefix() . 'DefaultNewsController');
// Generate the class name
- //* DEBUG: */ echo __METHOD__.": Controller=".$controllerName;
+ //* DEBUG: */ $this->debugOutput('BEFORE: controller=' . $controllerName);
if ($controllerName != $defaultController) {
// Create controller class name
- $className = $this->getControllerPrefix() . '' . $this->convertToClassName($controllerName) . 'Controller';
+ $className = $this->getClassPrefix() . $this->convertToClassName($controllerName) . 'Controller';
// ... and set it
$this->setClassName($className);
} else {
// No news at main command or non-news command
- $this->setClassName($this->getControllerPrefix() . 'DefaultNewsController');
+ $this->setClassName($this->getClassPrefix() . 'DefaultNewsController');
}
- //* DEBUG: */ echo ", controller=".$this->getClassName()."<br />\n";
+ //* DEBUG: */ $this->debugOutput('AFTER: controller=' . $this->getClassName());
// Is this class loaded?
if (!class_exists($this->getClassName())) {
$resolverConfigEntry = '';
// Try to read a config entry for our resolver including controller name... ;-)
- try {
- // Create the resolver name
- $resolverConfigEntry = sprintf("%s_cmd_%s_resolver_class", strtolower($this->getControllerPrefix()), 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
- // @TODO Maybe we need to log this?
- $resolverConfigEntry = strtolower($this->getControllerPrefix()) . '_cmd_resolver_class';
- }
+ $resolverConfigEntry = sprintf("%s_cmd_%s_resolver_class", strtolower($this->getClassPrefix()), strtolower($controllerName));
+
+ // Get the config, this will throw an exception if there is no special command resolver
+ $resolverClass = $this->getConfigInstance()->getConfigEntry($resolverConfigEntry);
// Initiate the resolver and controller
$resolverInstance = ObjectFactory::createObjectByConfiguredName(
} // END - if
// Create class name
- $className = $this->controllerPrefix . $this->convertToClassName($controllerName) . 'Controller';
+ $className = $this->getClassPrefix() . $this->convertToClassName($controllerName) . 'Controller';
// Now, let us create the full name of the controller class
$this->setClassName($className);
if (class_exists($this->getClassName())) {
// This class does exist. :-)
$isValid = true;
- } elseif ($this->getClassName() != $this->controllerPrefix.'DefaultNewsController') {
+ } elseif ($this->getClassName() != $this->getClassPrefix() . 'DefaultNewsController') {
// Set default controller
- $this->setClassName($this->controllerPrefix . 'DefaultNewsController');
+ $this->setClassName($this->getClassPrefix() . 'DefaultNewsController');
} else {
// All is tried, give it up here
throw new DefaultControllerException($this, self::EXCEPTION_DEFAULT_CONTROLLER_GONE);