public function createCityFromArray(array $data)
 {
     $requiredFields = array('id', 'name', 'country');
     if (isset($data['geoCountry']) && isset($data['geoCountry']['id'])) {
         $data['country'] = $this->getCountryById($data['geoCountry']['id']);
     }
     foreach ($requiredFields as $key) {
         if (!\array_key_exists($key, $data)) {
             throw LocationServiceException::missingRequiredCityDataKey($key);
         }
     }
     $city = new City();
     $city->setId($data['id']);
     $city->setName($data['name']);
     $city->setCountry($data['country']);
     $city->setInstitutionId(isset($data['institutionId']) ? $data['institutionId'] : 0);
     $city->setStatus(isset($data['status']) ? $data['status'] : City::STATUS_ACTIVE);
     if (isset($data['slug'])) {
         $city->setSlug($data['slug']);
     }
     /* Disabled to avoid duplicate persist!
           if(isset($data['geoState']) && isset($data['geoState']['id'])) {
            $state = $this->getStateById($data['geoState']['id']);
        if(!$state) {
       	    $data['geoState']['country'] = $data['country'];
       	    $state = $this->createStateFromArray($data['geoState']);
        }
        $city->setState($state);
        } */
     return $city;
 }
 public function get_city_url(City $city)
 {
     $params = array('country' => $city->getCountry()->getSlug(), 'city' => $city->getSlug());
     return $this->generator->generate('frontend_search_results_cities', $params, true);
 }