From: Roland Häder Date: Sat, 18 Jul 2009 07:20:14 +0000 (+0000) Subject: Is the XxxxDefaultController deprecated? X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=332e425d069ddea2ae259465ce43a946d6807cdf;p=hub.git Is the XxxxDefaultController deprecated? --- diff --git a/application/hub/class_ApplicationHelper.php b/application/hub/class_ApplicationHelper.php index b15862e2d..bc1f8c954 100644 --- a/application/hub/class_ApplicationHelper.php +++ b/application/hub/class_ApplicationHelper.php @@ -153,9 +153,52 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica * @return void */ public final function entryPoint () { + // Create a new request object + $requestInstance = ObjectFactory::createObjectByName('ConsoleRequest'); + + // Remember request instance here + $this->setRequestInstance($requestInstance); + + // Default response is console + $response = 'console'; + $responseType = 'console'; + + // Do we have another response? + if ($requestInstance->isRequestElementSet('request')) { + // Then use it + $response = strtolower($requestInstance->getRequestElement('request')); + $responseType = $response; + } // END - if + + // ... and a new response object + $responseClass = sprintf("%sResponse", $this->convertToClassName($response)); + $responseInstance = ObjectFactory::createObjectByName($responseClass, array($this)); + + // Remember response instance here + $this->setResponseInstance($responseInstance); + + // Get the parameter from the request + $commandName = $requestInstance->getRequestElement('page'); + + // If it is null then get default command + if (is_null($commandName)) { + $commandName = $responseInstance->getDefaultCommand(); + } // END - if + + // Get a resolver + $resolverClass = sprintf("%sControllerResolver", $this->convertToClassName($responseType)); + $resolverInstance = ObjectFactory::createObjectByName($resolverClass, array($commandName, $this)); + + // Get a controller instance as well + $this->controllerInstance = $resolverInstance->resolveController(); + + // Handle the request + $this->controllerInstance->handleRequest($requestInstance, $responseInstance); // ----------------------------- Init phase --------------------------- + // The default node-mode is from our configuration $nodeMode = $this->getConfigInstance()->readConfig('node_mode'); + die("Until here!\n"); // Prepare a ConsoleRequest class to catch all parameters $requestInstance = ObjectFactory::createObjectByName('ConsoleRequest'); @@ -179,6 +222,9 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica // Set the app instance $nodeInstance->setApplicationInstance($this); + + // Initialize all filters + $nodeInstance->initializeFilters(); } catch (ClassNotFoundException $e) { // This exception means, the node mode is invalid. // @TODO Can we rewrite this to app_die() ? @@ -242,7 +288,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica * @return $masterTemplateName Name of the master template */ public function buildMasterTemplateName () { - return "node_main"; + return 'node_main'; } } diff --git a/application/hub/config.php b/application/hub/config.php index 8065d1ec7..da92087de 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -81,5 +81,11 @@ $cfg->setConfigEntry('client_udp_listener_class', "ClientUdpListenerDecorator"); // CFG: CLIENT-POOL-CLASS $cfg->setConfigEntry('client_pool_class', "DefaultClientPool"); +// CFG: DEFAULT-CONSOLE-COMMAND +$cfg->setConfigEntry('default_console_command', "main"); + +// CFG: CONSOLE-CMD-RESOLVER-CLASS +$cfg->setConfigEntry('console_cmd_resolver_class', "ConsoleCommandResolver"); + // [EOF] ?>