<?php
+// Must be this namespace, else the launcher cannot find the class.
+namespace Org\Mxchange\CoreFramework\Helper\Application;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Loader\ClassLoader;
+use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
+use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+
/**
* A class holding general data about the application and some methods for
* the management including the entry point.
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @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
}
/**
- * 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(self::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', self::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');
} // END - if
// Get a controller resolver
- $resolverClass = self::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 --------------------------
+ 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.)');
}
/**
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());
+ }
+
+}