X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fcity%2Fclass_ApplicationHelper.php;h=9ced8a1907719485ae326bd48a50e8d3d00c1451;hb=b77ed87b8a501aa7cd4a7daba82d69ffaf712a2a;hp=ca061e497cd3d02bf0b652ff265326735364ec00;hpb=4e55bcf00e54f69328f8de3a1aaee1067dabf2c1;p=city.git diff --git a/application/city/class_ApplicationHelper.php b/application/city/class_ApplicationHelper.php index ca061e4..9ced8a1 100644 --- a/application/city/class_ApplicationHelper.php +++ b/application/city/class_ApplicationHelper.php @@ -1,4 +1,16 @@ * @version 0.0 - * @copyright Copyright (c) 2015 City Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 City Developer Team * @license GNU GPL 3.0 or any newer version * * This program is free software: you can redistribute it and/or modify @@ -144,37 +156,42 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica } /** - * Launches the test suite + * 1) Setups application data * * @return void */ - public final function entryPoint () { - // Set this application in registry - Registry::getRegistry()->addInstance('app', $this); - - // Default response is console - $response = $this->getResponseTypeFromSystem(); - $responseType = $this->getResponseTypeFromSystem(); - - // Create a new request object - $requestInstance = ObjectFactory::createObjectByName($this->convertToClassName($response) . 'Request'); - - // Remember request instance here - $this->setRequestInstance($requestInstance); + public function setupApplicationData () { + // Set all application data + $this->setAppName('City Growth Simulation'); + $this->setAppVersion('0.0.0'); + $this->setAppShortName('city'); + } - // Do we have another response? - if ($requestInstance->isRequestElementSet('request')) { - // Then use it - $response = strtolower($requestInstance->getRequestElement('request')); - $responseType = $response; - } // END - if + /** + * 2) Does initial stuff before starting the application + * + * @return void + */ + public function initApplication () { + // Initialize output system + ApplicationHelper::createDebugInstance('ApplicationHelper'); - // ... and a new response object - $responseClass = sprintf('%sResponse', $this->convertToClassName($response)); - $responseInstance = ObjectFactory::createObjectByName($responseClass, array($this)); + /* + * This application needs a database connection then simply call init + * method. + */ + FrameworkBootstrap::initDatabaseInstance(); + } - // Remember response instance here - $this->setResponseInstance($responseInstance); + /** + * 3) Launches the application + * + * @return void + */ + public function launchApplication () { + // Get request/response instances + $requestInstance = FrameworkBootstrap::getRequestInstance(); + $responseInstance = FrameworkBootstrap::getResponseInstance(); // Get the parameter from the request $commandName = $requestInstance->getRequestElement('command'); @@ -182,30 +199,33 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica // If it is null then get default command if (is_null($commandName)) { // Get default command - $commandName = $responseInstance->getDefaultCommand(); + $commandName = $responseInstance->determineDefaultCommand(); // Set it in request $requestInstance->setRequestElement('command', $commandName); } // END - if // Get a controller resolver - $resolverClass = $this->convertToClassName($this->getAppShortName() . '_' . $responseType . '_controller_resolver'); + $resolverClass = sprintf( + 'Org\Mxchange\City\Resolver\Controller\%s', + self::convertToClassName(sprintf( + '%s_%s_controller_resolver', + $this->getAppShortName(), + FrameworkBootstrap::getRequestTypeFromSystem() + )) + ); $resolverInstance = ObjectFactory::createObjectByName($resolverClass, array($commandName, $this)); // Get a controller instance as well $this->setControllerInstance($resolverInstance->resolveController()); - // Initialize language system - $languageInstance = ObjectFactory::createObjectByConfiguredName('language_system_class'); - - // And set it here - $this->setLanguageInstance($languageInstance); - - // Launch the game here + // Launch the test suite here $this->getControllerInstance()->handleRequest($requestInstance, $responseInstance); // -------------------------- Shutdown phase -------------------------- - // @TODO $this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown in progress ...'); + $this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown completed. (This is the last line.)'); } /** @@ -230,7 +250,16 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica public function buildMasterTemplateName () { return 'city_main'; } -} -// [EOF] -?> + /** + * Assigns extra application-depending data + * + * @param $templateInstance An instance of a CompileableTemplate + * @return void + * @todo Nothing to add? + */ + public function assignExtraTemplateData (CompileableTemplate $templateInstance) { + $this->partialStub('Unfinished method. templateInstance=' . $templateInstance->__toString()); + } + +}