Renamed exception (in 'core') + updated 'core'.
authorRoland Haeder <roland@mxchange.org>
Wed, 10 Jun 2015 19:46:41 +0000 (21:46 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 10 Jun 2015 19:46:41 +0000 (21:46 +0200)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/city/main/city/class_BaseCity.php
application/city/main/states/city/class_BaseCityState.php
application/city/main/states/city/virgin/class_CityVirginState.php
core

index aa3d1eed8830f3d4a79ebe48f7b6ca14376e9de1..e6243f5d8114f40dc8b283fd30b7cf728e5dd878 100644 (file)
@@ -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
        }
index fb05751dc55f51d4a6360bfbcaf7c88d4d2b6527..00a43b6403ed3db941b8a3aecd2741a17c879a11 100644 (file)
@@ -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
        }
 }
index 14c53a59a4c10c2b75e73a403c4d5f1640cc6260..9a43b87f36a5b754827b3525f6e3b3927de76c3a 100644 (file)
@@ -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 cc0e0b439900fd1ffb882f9150f37dd3eb8d301d..c33ae28f2865cdcfb330dbbc6e8159b1d17b9ce0 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit cc0e0b439900fd1ffb882f9150f37dd3eb8d301d
+Subproject commit c33ae28f2865cdcfb330dbbc6e8159b1d17b9ce0