Ejemplo n.º 1
0
 /**
  * Return if a province is equal than current
  *
  * @param ProvinceInterface $province Province to be compared with
  *
  * @return boolean Provinces are the same
  */
 public function equals(ProvinceInterface $province)
 {
     return $province->getId() === $this->getId();
 }
Ejemplo n.º 2
0
 /**
  * Add a city with the premise that the province has to be added already
  *
  * @param ProvinceInterface $province Province
  * @param string            $cityName City name
  *
  * @return CityInterface
  */
 public function addCity(ProvinceInterface $province, $cityName)
 {
     $cityName = trim($cityName);
     $cityId = $province->getId() . '_' . preg_replace('/[^\\da-z]/i', '', strtolower($cityName));
     if (!isset($this->cities[$cityId])) {
         $city = $this->cityFactory->create();
         $city->setId($cityId)->setName($cityName)->setProvince($province)->setPostalCodes(new ArrayCollection())->setEnabled(true);
         $province->addCity($city);
         $this->cities[$cityId] = $city;
     }
     return $this->cities[$cityId];
 }