X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fcity%2Fclass_ApplicationHelper.php;h=5aa8b14a4a821214a5761c26979a6afd27f82868;hb=083892d43cd5e566fba63c0ef6d1c75dde5944f2;hp=da8b31b5713e6a8d03f8c7d4b2ab3031348ffa7e;hpb=96d2d387d93b7ad25861256a54b889b03f40ba0b;p=city.git diff --git a/application/city/class_ApplicationHelper.php b/application/city/class_ApplicationHelper.php index da8b31b..5aa8b14 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 @@ -38,7 +50,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplication, Registerable { +class ApplicationHelper extends BaseApplication implements ManageableApplication, Registerable { /** * The version number of this application */ @@ -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 = self::getResponseTypeFromSystem(); - $responseType = self::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,14 +199,21 @@ 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 @@ -201,21 +225,13 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica // And set it here $this->setLanguageInstance($languageInstance); - // Launch the game here + // Launch the test suite here $this->getControllerInstance()->handleRequest($requestInstance, $responseInstance); // -------------------------- Shutdown phase -------------------------- + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown in progress ...'); $this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance); - } - - /** - * Assigns extra application-depending data - * - * @param $templateInstance An instance of a CompileableTemplate - * @return void - * @todo Nothing to add? - */ - public function assignExtraTemplateData (CompileableTemplate $templateInstance) { + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown completed. (This is the last line.)'); } /** @@ -240,7 +256,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()); + } + +}