From 7dbafe9738dfbc67b085ea983cc09c919a912fd6 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 28 Jun 2015 21:45:00 +0200 Subject: [PATCH] Renamed some more files city -> city_daemon to avoid confusion as these classes are only for the daemon and not for any frontends. Signed-off-by: Roland Haeder --- application/city/config.php | 6 ++ .../city/class_CityInformationWrapper.php | 2 +- .../helper/city/class_CityHelper.php | 7 ++ .../city/main/{city => city_daemon}/.htaccess | 0 .../city/main/{city => city_daemon}/class_ | 6 +- .../class_BaseCityDaemon.php} | 21 +++++- .../{city => city_daemon}/testing/.htaccess | 0 .../class_SimulationTestingCityDaemon.php} | 11 ++- .../class_CityConsoleDaemonCommand.php | 4 +- .../class_CityInformationDatabaseWrapper.php | 2 +- ....php => class_CityDaemonObjectFactory.php} | 11 ++- .../states/city/class_CityStateFactory.php | 8 ++- .../city/main/filter/bootstrap/.htaccess | 1 + .../bootstrap/class_CityDaemonBootstrap | 67 +++++++++++++++++++ .../city/main/filter/bootstrap/init/.htaccess | 1 + ...ss_CityDaemonBootstrapInitDaemonFilter.php | 67 +++++++++++++++++++ .../class_CityDaemonInitializationFilter.php | 7 +- .../class_CityDaemonWelcomeTeaserFilter.php | 2 +- .../class_CityDaemonShutdownCityFilter.php | 2 +- ...CityDaemonTaskHandlerInitializerFilter.php | 2 +- .../city/active/class_CityActiveState.php | 5 +- application/city/main/states/city/class_ | 6 +- .../states/city/init/class_CityInitState.php | 24 ++++++- .../city/virgin/class_CityVirginState.php | 3 +- core | 2 +- 25 files changed, 221 insertions(+), 46 deletions(-) rename application/city/main/{city => city_daemon}/.htaccess (100%) rename application/city/main/{city => city_daemon}/class_ (91%) rename application/city/main/{city/class_BaseCity.php => city_daemon/class_BaseCityDaemon.php} (93%) rename application/city/main/{city => city_daemon}/testing/.htaccess (100%) rename application/city/main/{city/testing/class_SimulationTestingCity.php => city_daemon/testing/class_SimulationTestingCityDaemon.php} (84%) rename application/city/main/factories/city/{class_CityObjectFactory.php => class_CityDaemonObjectFactory.php} (89%) create mode 100644 application/city/main/filter/bootstrap/.htaccess create mode 100644 application/city/main/filter/bootstrap/class_CityDaemonBootstrap create mode 100644 application/city/main/filter/bootstrap/init/.htaccess create mode 100644 application/city/main/filter/bootstrap/init/class_CityDaemonBootstrapInitDaemonFilter.php diff --git a/application/city/config.php b/application/city/config.php index 527502c..ab67804 100644 --- a/application/city/config.php +++ b/application/city/config.php @@ -52,6 +52,9 @@ $cfg->setConfigEntry('region_map_db_wrapper_class', 'RegionMapDatabaseWrapper'); // CFG: CITY-INIT-STATE-CLASS $cfg->setConfigEntry('city_init_state_class', 'CityInitState'); +// CFG: CITY-VIRGIN-STATE-CLASS +$cfg->setConfigEntry('city_virgin_state_class', 'CityVirginState'); + /****************************************************************************** * HTML client * ******************************************************************************/ @@ -510,6 +513,9 @@ $cfg->setConfigEntry('city_daemon_activation_task_handler_initializer_filter', ' // CFG: CITY-DAEMON-WELCOME-TEASER-FILTER $cfg->setConfigEntry('city_daemon_welcome_teaser_filter', 'CityDaemonWelcomeTeaserFilter'); +// CFG: CITY-DAEMON-BOOTSTRAP-INIT-DAEMON-FILTER +$cfg->setConfigEntry('city_daemon_bootstrap_init_daemon_filter', 'CityDaemonBootstrapInitDaemonFilter'); + // CFG: CITY-DAEMON-SHUTDOWN-TASK-HANDLER-FILTER $cfg->setConfigEntry('city_daemon_shutdown_task_handler_filter', 'CityDaemonShutdownTaskHandlerFilter'); diff --git a/application/city/interfaces/database/frontend/city/class_CityInformationWrapper.php b/application/city/interfaces/database/frontend/city/class_CityInformationWrapper.php index 9484065..7c45cf0 100644 --- a/application/city/interfaces/database/frontend/city/class_CityInformationWrapper.php +++ b/application/city/interfaces/database/frontend/city/class_CityInformationWrapper.php @@ -30,7 +30,7 @@ interface CityInformationWrapper extends DatabaseWrapper { * @param $requestInstance An instance of a Requestable class * @return void */ - function registerCityId (BaseCity $cityInstance, Requestable $requestInstance); + function registerCityId (BaseCityDaemon $cityInstance, Requestable $requestInstance); /** * Checks whether there is an entry for given city instance diff --git a/application/city/interfaces/helper/city/class_CityHelper.php b/application/city/interfaces/helper/city/class_CityHelper.php index 7f3e0e3..bf4a413 100644 --- a/application/city/interfaces/helper/city/class_CityHelper.php +++ b/application/city/interfaces/helper/city/class_CityHelper.php @@ -22,6 +22,13 @@ * along with this program. If not, see . */ interface CityHelper extends Helper, AddableCriteria { + /** + * Initializes the city daemon + * + * @return void + */ + function bootstrapInitCityDaemon (); + /** * Method to "bootstrap" the city. This step does also apply provided * command-line arguments stored in the request instance. You should now diff --git a/application/city/main/city/.htaccess b/application/city/main/city_daemon/.htaccess similarity index 100% rename from application/city/main/city/.htaccess rename to application/city/main/city_daemon/.htaccess diff --git a/application/city/main/city/class_ b/application/city/main/city_daemon/class_ similarity index 91% rename from application/city/main/city/class_ rename to application/city/main/city_daemon/class_ index 19410ec..94302a2 100644 --- a/application/city/main/city/class_ +++ b/application/city/main/city_daemon/class_ @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class Simulation???City extends BaseCity implements CityHelper, Registerable { +class Simulation???CityDaemon extends BaseCity implements CityHelper, Registerable { /** * Protected constructor * @@ -38,9 +38,9 @@ class Simulation???City extends BaseCity implements CityHelper, Registerable { * @param $requestInstance An instance of a Requestable class * @return $nodeInstance An instance of this hub-node class */ - public final static function createCity???City (Requestable $requestInstance) { + public final static function createSimulation???CityDaemon (Requestable $requestInstance) { // Get a new instance - $nodeInstance = new City???City(); + $nodeInstance = new Simulation???CityDaemon(); // Set the request instance $nodeInstance->setRequestInstance($requestInstance); diff --git a/application/city/main/city/class_BaseCity.php b/application/city/main/city_daemon/class_BaseCityDaemon.php similarity index 93% rename from application/city/main/city/class_BaseCity.php rename to application/city/main/city_daemon/class_BaseCityDaemon.php index e6243f5..661c613 100644 --- a/application/city/main/city/class_BaseCity.php +++ b/application/city/main/city_daemon/class_BaseCityDaemon.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseCity extends BaseCitySystem implements Updateable, AddableCriteria { +class BaseCityDaemon extends BaseCitySystem implements Updateable, AddableCriteria { /** * City types */ @@ -54,6 +54,9 @@ class BaseCity extends BaseCitySystem implements Updateable, AddableCriteria { // Set it here $this->setCryptoInstance($cryptoInstance); + // Add own instance to registry + Registry::getRegistry()->addInstance('city', $this); + // Init state which sets the state to 'init' $this->initState(); } @@ -65,7 +68,7 @@ class BaseCity extends BaseCitySystem implements Updateable, AddableCriteria { */ private function initState() { // Get the state factory and create the initial state. - CityStateFactory::createCityStateInstanceByName('init', $this); + CityStateFactory::createCityStateInstanceByName('init'); } /** @@ -176,7 +179,7 @@ class BaseCity extends BaseCitySystem implements Updateable, AddableCriteria { $controllerInstance->executeActivationFilters($requestInstance, $responseInstance); // Make sure the city's state is 'virigin' - assert($this->getStateInstance()->validateCityStateIsVirgin() === TRUE); + $this->getStateInstance()->validateCityStateIsVirgin(); // ----------------------- Last step from here ------------------------ // Activate the City. This is ALWAYS the last step in this method @@ -235,6 +238,18 @@ class BaseCity extends BaseCitySystem implements Updateable, AddableCriteria { } } // END - foreac } + + /** + * Initializes the city daemon + * + * @return void + */ + public function bootstrapInitCityDaemon () { + $this->partialStub('Please add something here.'); + + // Daemon has been fully initialized, so change state to 'virgin' + $this->getStateInstance()->daemonHasInitialized(); + } } // [EOF] diff --git a/application/city/main/city/testing/.htaccess b/application/city/main/city_daemon/testing/.htaccess similarity index 100% rename from application/city/main/city/testing/.htaccess rename to application/city/main/city_daemon/testing/.htaccess diff --git a/application/city/main/city/testing/class_SimulationTestingCity.php b/application/city/main/city_daemon/testing/class_SimulationTestingCityDaemon.php similarity index 84% rename from application/city/main/city/testing/class_SimulationTestingCity.php rename to application/city/main/city_daemon/testing/class_SimulationTestingCityDaemon.php index 798e3de..4931779 100644 --- a/application/city/main/city/testing/class_SimulationTestingCity.php +++ b/application/city/main/city_daemon/testing/class_SimulationTestingCityDaemon.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class SimulationTestingCity extends BaseCity implements CityHelper, Registerable { +class SimulationTestingCityDaemon extends BaseCityDaemon implements CityHelper, Registerable { /** * Protected constructor * @@ -38,9 +38,9 @@ class SimulationTestingCity extends BaseCity implements CityHelper, Registerable * @param $requestInstance An instance of a Requestable class * @return $nodeInstance An instance of this hub-node class */ - public static final function createSimulationTestingCity (Requestable $requestInstance) { + public static final function createSimulationTestingCityDaemon (Requestable $requestInstance) { // Get a new instance - $nodeInstance = new SimulationTestingCity(); + $nodeInstance = new SimulationTestingCityDaemon(); // Set the request instance $nodeInstance->setRequestInstance($requestInstance); @@ -50,9 +50,8 @@ class SimulationTestingCity extends BaseCity implements CityHelper, Registerable } /** - * Method to "bootstrap" the node. This step does also apply provided - * command-line arguments stored in the request instance. The regular node - * should communicate with the bootstrap-nodes at this point. + * Method to "bootstrap" the city simulation. This step does also apply + * provided command-line arguments stored in the request instance. * * @return void * @todo Implement this method diff --git a/application/city/main/commands/console/class_CityConsoleDaemonCommand.php b/application/city/main/commands/console/class_CityConsoleDaemonCommand.php index 80c3691..a49d86d 100644 --- a/application/city/main/commands/console/class_CityConsoleDaemonCommand.php +++ b/application/city/main/commands/console/class_CityConsoleDaemonCommand.php @@ -72,7 +72,7 @@ class CityConsoleDaemonCommand extends BaseCommand implements Commandable { self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); // Get city instance - $cityInstance = CityObjectFactory::createCityInstance(); + $cityInstance = CityDaemonObjectFactory::createCityDaemonInstance(); // Add some city-specific filters, e.g. announcement $cityInstance->addExtraCityFilters(); @@ -120,7 +120,7 @@ class CityConsoleDaemonCommand extends BaseCommand implements Commandable { $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_welcome_teaser_filter')); // Add bootstrap filters - //$controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_bootstrap_generate_cityid_filter')); + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_bootstrap_init_daemon_filter')); // Add city activation filters $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_activation_task_handler_initializer_filter')); diff --git a/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php b/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php index 9322280..6bebe8f 100644 --- a/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php +++ b/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php @@ -94,7 +94,7 @@ class CityInformationDatabaseWrapper extends BaseDatabaseWrapper implements City * @param $requestInstance An instance of a Requestable class * @return void */ - public function registerCityId (BaseCity $cityInstance, Requestable $requestInstance) { + public function registerCityId (BaseCityDaemon $cityInstance, Requestable $requestInstance) { // Get a dataset instance $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_CITY_INFORMATION)); diff --git a/application/city/main/factories/city/class_CityObjectFactory.php b/application/city/main/factories/city/class_CityDaemonObjectFactory.php similarity index 89% rename from application/city/main/factories/city/class_CityObjectFactory.php rename to application/city/main/factories/city/class_CityDaemonObjectFactory.php index a4be719..0acfe5f 100644 --- a/application/city/main/factories/city/class_CityObjectFactory.php +++ b/application/city/main/factories/city/class_CityDaemonObjectFactory.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class CityObjectFactory extends ObjectFactory { +class CityDaemonObjectFactory extends ObjectFactory { /** * Protected constructor * @@ -40,9 +40,9 @@ class CityObjectFactory extends ObjectFactory { * @return $cityInstance An instance of a CityHelper class * @throws FactoryRequiredParameterException If not all parameters are set and no instance 'city' is set. */ - public static final function createCityInstance (Requestable $requestInstance = NULL, Responseable $responseInstance = NULL) { + public static final function createCityDaemonInstance (Requestable $requestInstance = NULL, Responseable $responseInstance = NULL) { // Get new factory instance - $factoryInstance = new CityObjectFactory(); + $factoryInstance = new CityDaemonObjectFactory(); // If there is no handler? if (Registry::getRegistry()->instanceExists('city')) { @@ -62,7 +62,7 @@ class CityObjectFactory extends ObjectFactory { } // Now convert the city-mode in a class name - $className = 'Simulation' . $factoryInstance->convertToClassName($cityMode) . 'City'; + $className = 'Simulation' . $factoryInstance->convertToClassName($cityMode) . 'CityDaemon'; // Get the city instance $cityInstance = ObjectFactory::createObjectByName($className, array($requestInstance)); @@ -75,9 +75,6 @@ class CityObjectFactory extends ObjectFactory { // Add city-specific filters $cityInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); - - // Add it to the registry - Registry::getRegistry()->addInstance('city', $cityInstance); } else { // Throw an exception here throw new FactoryRequiredParameterException($factoryInstance, self::EXCEPTION_FACTORY_REQUIRE_PARAMETER); diff --git a/application/city/main/factories/states/city/class_CityStateFactory.php b/application/city/main/factories/states/city/class_CityStateFactory.php index 8c8fffe..6a7794a 100644 --- a/application/city/main/factories/states/city/class_CityStateFactory.php +++ b/application/city/main/factories/states/city/class_CityStateFactory.php @@ -37,15 +37,17 @@ class CityStateFactory extends ObjectFactory { * given city instance. * * @param $stateName Name of the state - * @param $cityInstance A CityHelper class instance * @return $stateInstance A Stateable class instance */ - public static final function createCityStateInstanceByName ($stateName, CityHelper $cityInstance) { + public static final function createCityStateInstanceByName ($stateName) { // Then construct the class' configuraton entry $className = 'city_' . $stateName . '_state_class'; // Get a class from that configuration entry - $stateInstance = self::createObjectByConfiguredName($className, array($cityInstance)); + $stateInstance = self::createObjectByConfiguredName($className); + + // Get city instance + $cityInstance = Registry::getRegistry()->getInstance('city'); // Debug message self::createDebugInstance(__CLASS__)->debugOutput('CITY-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: City state has changed from ' . $cityInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); diff --git a/application/city/main/filter/bootstrap/.htaccess b/application/city/main/filter/bootstrap/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/filter/bootstrap/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/filter/bootstrap/class_CityDaemonBootstrap b/application/city/main/filter/bootstrap/class_CityDaemonBootstrap new file mode 100644 index 0000000..9ac5ede --- /dev/null +++ b/application/city/main/filter/bootstrap/class_CityDaemonBootstrap @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CityDaemonBootstrap???Filter extends BaseCityFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createCityDaemonBootstrap???Filter () { + // Get a new instance + $filterInstance = new CityDaemonBootstrap???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $cityInstance is null (no NullPointerException here) + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get city instance + $cityInstance = Registry::getRegistry()->getInstance('city'); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/city/main/filter/bootstrap/init/.htaccess b/application/city/main/filter/bootstrap/init/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/filter/bootstrap/init/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/filter/bootstrap/init/class_CityDaemonBootstrapInitDaemonFilter.php b/application/city/main/filter/bootstrap/init/class_CityDaemonBootstrapInitDaemonFilter.php new file mode 100644 index 0000000..842f620 --- /dev/null +++ b/application/city/main/filter/bootstrap/init/class_CityDaemonBootstrapInitDaemonFilter.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CityDaemonBootstrapInitDaemonFilter extends BaseCityFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createCityDaemonBootstrapInitDaemonFilter () { + // Get a new instance + $filterInstance = new CityDaemonBootstrapInitDaemonFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $cityInstance is null (no NullPointerException here) + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get city instance + $cityInstance = Registry::getRegistry()->getInstance('city'); + + // Now bootstrap the daemon + $cityInstance->bootstrapInitCityDaemon(); + } +} + +// [EOF] +?> diff --git a/application/city/main/filter/city_daemon/class_CityDaemonInitializationFilter.php b/application/city/main/filter/city_daemon/class_CityDaemonInitializationFilter.php index 73a78a0..108b6c5 100644 --- a/application/city/main/filter/city_daemon/class_CityDaemonInitializationFilter.php +++ b/application/city/main/filter/city_daemon/class_CityDaemonInitializationFilter.php @@ -56,16 +56,15 @@ class CityDaemonInitializationFilter extends BaseCityFilter implements Filterabl // Try to instance it by using a factory try { // Get an instance - $cityInstance = CityObjectFactory::createCityInstance($requestInstance, $responseInstance); + $cityInstance = CityDaemonObjectFactory::createCityDaemonInstance($requestInstance, $responseInstance); } catch (ClassNotFoundException $e) { // This exception means, the city mode is invalid. // @TODO Can we rewrite this to app_exit() ? $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: city mode ' . $cityMode . ' is invalid.'); } - // Set the city instance in registry - Registry::getRegistry()->addInstance('city', $cityInstance); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-INIT-FILTER[' . __METHOD__ . ':' . __LINE__ . ']: City ' . $cityMode . ' has been added to registry.'); + // Debug message + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-INIT-FILTER[' . __METHOD__ . ':' . __LINE__ . ']: City daemon ' . $cityMode . ' has been added to registry.'); } } diff --git a/application/city/main/filter/city_daemon/class_CityDaemonWelcomeTeaserFilter.php b/application/city/main/filter/city_daemon/class_CityDaemonWelcomeTeaserFilter.php index 936980c..caf11ed 100644 --- a/application/city/main/filter/city_daemon/class_CityDaemonWelcomeTeaserFilter.php +++ b/application/city/main/filter/city_daemon/class_CityDaemonWelcomeTeaserFilter.php @@ -56,7 +56,7 @@ class CityDaemonWelcomeTeaserFilter extends BaseCityFilter implements Filterable */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get city instance - $cityInstance = CityObjectFactory::createCityInstance(); + $cityInstance = CityDaemonObjectFactory::createCityDaemonInstance(); // Now output the teaser $cityInstance->outputConsoleTeaser(); diff --git a/application/city/main/filter/shutdown/city/class_CityDaemonShutdownCityFilter.php b/application/city/main/filter/shutdown/city/class_CityDaemonShutdownCityFilter.php index 624d2f2..9a0faed 100644 --- a/application/city/main/filter/shutdown/city/class_CityDaemonShutdownCityFilter.php +++ b/application/city/main/filter/shutdown/city/class_CityDaemonShutdownCityFilter.php @@ -57,7 +57,7 @@ class CityDaemonShutdownCityFilter extends BaseCityFilter implements Filterable */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get city instance - $cityInstance = CityObjectFactory::createCityInstance(); + $cityInstance = CityDaemonObjectFactory::createCityDaemonInstance(); // Shutdown the city. This should be the last line $cityInstance->doShutdown(); diff --git a/application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php b/application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php index 542aa27..bf6fff1 100644 --- a/application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php +++ b/application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php @@ -56,7 +56,7 @@ class CityDaemonTaskHandlerInitializerFilter extends BaseCityFilter implements F */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get city instance - $cityInstance = CityObjectFactory::createCityInstance(); + $cityInstance = CityDaemonObjectFactory::createCityDaemonInstance(); // Get a new task handler instance $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); diff --git a/application/city/main/states/city/active/class_CityActiveState.php b/application/city/main/states/city/active/class_CityActiveState.php index 1a1b745..b3956da 100644 --- a/application/city/main/states/city/active/class_CityActiveState.php +++ b/application/city/main/states/city/active/class_CityActiveState.php @@ -38,15 +38,14 @@ class CityActiveState extends BaseCityState implements Stateable { /** * Creates an instance of this class * - * @param $cityInstance An instance of a CityHelper class * @return $stateInstance An instance of a Stateable class */ - public static final function createCityActiveState (CityHelper $cityInstance) { + public static final function createCityActiveState () { // Get new instance $stateInstance = new CityActiveState(); // Get city instance and set 'active' flag - CityObjectFactory::createCityInstance()->enableIsActive(); + CityDaemonObjectFactory::createCityDaemonInstance()->enableIsActive(); // Return the prepared instance return $stateInstance; diff --git a/application/city/main/states/city/class_ b/application/city/main/states/city/class_ index 250c39d..a1f38ca 100644 --- a/application/city/main/states/city/class_ +++ b/application/city/main/states/city/class_ @@ -38,16 +38,12 @@ class City???State extends BaseCityState implements Stateable { /** * Creates an instance of this class * - * @param $cityInstance An instance of a CityHelper class * @return $stateInstance An instance of a Stateable class */ - public final static function createCity???State (CityHelper $cityInstance) { + public final static function createCity???State () { // Get new instance $stateInstance = new City???State(); - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY-STATE: Has changed from ' . $cityInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - // Return the prepared instance return $stateInstance; } diff --git a/application/city/main/states/city/init/class_CityInitState.php b/application/city/main/states/city/init/class_CityInitState.php index ea9d5b8..e5765b2 100644 --- a/application/city/main/states/city/init/class_CityInitState.php +++ b/application/city/main/states/city/init/class_CityInitState.php @@ -38,16 +38,36 @@ class CityInitState extends BaseCityState implements Stateable { /** * Creates an instance of this class * - * @param $cityInstance An instance of a CityHelper class * @return $stateInstance An instance of a Stateable class */ - public static final function createCityInitState (CityHelper $cityInstance) { + public static final function createCityInitState () { // Get new instance $stateInstance = new CityInitState(); // Return the prepared instance return $stateInstance; } + + /** + * Executes the state with given Executor instance + * + * @param $executorInstance An instance of a Executor class + * @return void + */ + public function executeState (Executor $executorInstance) { + // Initialize the daemon + $executorInstance->initializeDaemon($this); + } + + /** + * The daemon has been fully initialized so change the state to 'virgin'. + * + * @return void + */ + public function daemonHasInitialized () { + // Change the state now to 'virgin' + CityStateFactory::createCityStateInstanceByName('virgin'); + } } // [EOF] diff --git a/application/city/main/states/city/virgin/class_CityVirginState.php b/application/city/main/states/city/virgin/class_CityVirginState.php index 9a43b87..a86b73f 100644 --- a/application/city/main/states/city/virgin/class_CityVirginState.php +++ b/application/city/main/states/city/virgin/class_CityVirginState.php @@ -38,10 +38,9 @@ class CityVirginState extends BaseCityState implements Stateable { /** * Creates an instance of this class * - * @param $cityInstance An instance of a CityHelper class * @return $stateInstance An instance of a Stateable class */ - public static final function createCityVirginState (CityHelper $cityInstance) { + public static final function createCityVirginState () { // Get new instance $stateInstance = new CityVirginState(); diff --git a/core b/core index c33ae28..1c6401b 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit c33ae28f2865cdcfb330dbbc6e8159b1d17b9ce0 +Subproject commit 1c6401b0efc57aaf1735d05c260be92499cc6e32 -- 2.39.5