Example #1
0
 /**
  * @param ZoneInterface $zone
  * @param CityInterface $city
  *
  * @return boolean City is contained in zone
  */
 public function isCityContainedInZone(ZoneInterface $zone, CityInterface $city)
 {
     return $zone->getMembers()->filter(function (ZoneMemberInterface $zoneMember) {
         return $zoneMember instanceof ZoneCityMemberInterface;
     })->exists(function ($_, ZoneCityMemberInterface $zoneCityMember) use($city) {
         return $city->equals($zoneCityMember->getCity());
     });
 }
Example #2
0
 /**
  * Return if a city is equal than current
  *
  * @param CityInterface $city City to be compared with
  *
  * @return boolean Cities are the same
  */
 public function equals(CityInterface $city)
 {
     return $city->getId() === $this->getId();
 }
Example #3
0
 /**
  * Add a postalcode with the premise that the city has to be added already
  *
  * @param CityInterface $city           City
  * @param string        $postalCodeCode Postalcode code
  *
  * @return PostalCodeInterface
  */
 public function addPostalCode(CityInterface $city, $postalCodeCode)
 {
     $postalCodeCode = trim($postalCodeCode);
     $cityCountry = $city->getCountry();
     $postalCodeId = $cityCountry->getCode() . '_' . trim($postalCodeCode);
     if (!isset($this->postalCodes[$postalCodeId])) {
         $postalCode = $this->postalCodeFactory->create();
         $postalCode->setId($postalCodeId)->setCode($postalCodeCode)->setCities(new ArrayCollection())->addCity($city)->setEnabled(true);
         $city->addPostalCode($postalCode);
         $this->postalCodes[$postalCodeId] = $postalCode;
     }
     return $this->postalCodes[$postalCodeId];
 }