// Return result
return $isTaken;
}
+
+ /**
+ * Founds the first city. A dummy region will also be created
+ *
+ * @return void
+ */
+ public function foundFirstCity () {
+ // Check on request instance and 'city_name' element
+ assert($this->getRequestInstance() instanceof Requestable);
+ assert($this->getRequestInstance()->isRequestElementSet(CityInformationDatabaseWrapper::DB_COLUMN_CITY_NAME));
+
+ // Get city name
+ $cityName = $this->getRequestInstance()->getRequestElement(CityInformationDatabaseWrapper::DB_COLUMN_CITY_NAME);
+
+ // Some pre-checks
+ assert(!$this->isCityAlreadyFounded());
+ assert(!$this->ifCityNameExists($cityName));
+
+ // Get region manager
+ $managerInstance = ManagerFactory::createManagerByType('region');
+
+ // There should be no region created
+ assert(!$managerInstance->ifUserHasCreatedRegion());
+
+ // Create first region and get back whole result
+ $regionResultInstance = $managerInstance->createFirstRegion();
+
+ // Get current entry
+ $regionData = $regionResultInstance->current();
+
+ // Add region id from it
+ $this->getRequestInstance()->setRequestElement(CityInformationDatabaseWrapper::DB_COLUMN_CITY_REGION_ID, $regionData[RegionInformationDatabaseWrapper::DB_COLUMN_REGION_ID]);
+
+ // Then create the first city
+ $this->getWrapperInstance()->createCityByRequest($this->getRequestInstance());
+ }
}
// [EOF]