From da19cc86ec352a80c1667b9652fbda4c0804f847 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 10 Jun 2015 21:46:41 +0200 Subject: [PATCH] Renamed exception (in 'core') + updated 'core'. Signed-off-by: Roland Haeder --- application/city/main/city/class_BaseCity.php | 6 +++++- .../main/states/city/class_BaseCityState.php | 19 +++++++++++++++++-- .../city/virgin/class_CityVirginState.php | 5 ++--- core | 2 +- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/application/city/main/city/class_BaseCity.php b/application/city/main/city/class_BaseCity.php index aa3d1ee..e6243f5 100644 --- a/application/city/main/city/class_BaseCity.php +++ b/application/city/main/city/class_BaseCity.php @@ -175,8 +175,12 @@ class BaseCity extends BaseCitySystem implements Updateable, AddableCriteria { // Run all filters for the City activation $controllerInstance->executeActivationFilters($requestInstance, $responseInstance); + // Make sure the city's state is 'virigin' + assert($this->getStateInstance()->validateCityStateIsVirgin() === TRUE); + // ----------------------- Last step from here ------------------------ // Activate the City. This is ALWAYS the last step in this method + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getStateInstance()->__toString()); $this->getStateInstance()->citySimulationIsActivated(); // ---------------------- Last step until here ------------------------ } @@ -227,7 +231,7 @@ class BaseCity extends BaseCitySystem implements Updateable, AddableCriteria { $dataSetInstance->addCriteria($element, $cityData[$element]); } else { // Output warning message - /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('City[' . __METHOD__ . ':' . __LINE__ . ']: addArrayToDataSet(): Element ' . $element . ' not found in CityData array.'); + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY[' . __METHOD__ . ':' . __LINE__ . ']: addArrayToDataSet(): Element ' . $element . ' not found in CityData array.'); } } // END - foreac } diff --git a/application/city/main/states/city/class_BaseCityState.php b/application/city/main/states/city/class_BaseCityState.php index fb05751..00a43b6 100644 --- a/application/city/main/states/city/class_BaseCityState.php +++ b/application/city/main/states/city/class_BaseCityState.php @@ -38,13 +38,28 @@ class BaseCityState extends BaseState { * it is every other state. * * @return void - * @throws InvalidStateException If the state is not 'active' + * @throws UnexpectedStateException If the state is not 'active' */ public function validateCityStateIsActive () { // Just compare it... if (!$this instanceof CityActiveState) { // Throw the exception - throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE); + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } + + /** + * Validates whether the state is 'virgin' or throws an exception if + * it is every other state. + * + * @return void + * @throws UnexpectedStateException If the state is not 'virgin' + */ + public function validateCityStateIsVirgin () { + // Just compare it... + if (!$this instanceof CityVirginState) { + // Throw the exception + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); } // END - if } } diff --git a/application/city/main/states/city/virgin/class_CityVirginState.php b/application/city/main/states/city/virgin/class_CityVirginState.php index 14c53a5..9a43b87 100644 --- a/application/city/main/states/city/virgin/class_CityVirginState.php +++ b/application/city/main/states/city/virgin/class_CityVirginState.php @@ -50,16 +50,15 @@ class CityVirginState extends BaseCityState implements Stateable { } /** - * Change the state to 'active' when the city simulation has initialized all + * Change the state to 'active' when the city daemon has initialized all * tasks, queues, etc. * * @return void */ - public function citySimulationIsActivated () { + public function cityIsActivated () { // Create the new state instance CityStateFactory::createCityStateInstanceByName('active'); } - } // [EOF] diff --git a/core b/core index cc0e0b4..c33ae28 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit cc0e0b439900fd1ffb882f9150f37dd3eb8d301d +Subproject commit c33ae28f2865cdcfb330dbbc6e8159b1d17b9ce0 -- 2.39.5