/** * @param City $city * @param Department $department */ protected function removeCity($city, $department) { $departmentId = $department->getId(); if (!isset($this->removeCities[$departmentId])) { $this->removeCities[$departmentId] = array(); } $this->removeCities[$departmentId][] = $city->getId(); }
/** * @param City $city * * @return $this */ public function removeCity($city) { $this->cityType->deleteById($city->getId()); }
/** * Get linkedCity * * @return City */ public function getLinkedCityLowestDistance() { /** @var array $toReturn */ $toReturn = array(); /** @var City $linkedCity */ foreach ($this->linkedCities as $linkedCity) { if ($linkedCity->getId() != $this->city->getId()) { $distance = 0; if ($linkedCity->getLatitude() && $linkedCity->getLongitude() && $this->latitude && $this->longitude) { $distance = GeolocManager::calculateDistance($linkedCity->getLatitude(), $linkedCity->getLongitude(), $this->latitude, $this->longitude); } if ($distance > 0) { $linkedCity->setDistance($distance); $toReturn[] = $linkedCity; } } } usort($toReturn, function ($a, $b) { if ($a->getDistance() > $b->getDistance()) { return 1; } elseif ($a->getDistance() < $b->getDistance()) { return -1; } return 0; }); return array_shift($toReturn); }
/** * @param City $city * @return array */ public function findNbForCityAndBrand($city, $brandId = null) { $cityId = $city; if ($city instanceof City) { $cityId = $city->getId(); } $qb = $this->getValidQueryBuilder()->andWhere('(ci.id = :city OR :city MEMBER OF h.linkedCities)')->setParameter(':city', $cityId)->select('COUNT(DISTINCT h.id) as nbHotels'); if ($brandId != null) { $qb->andWhere('b.id = :idBrand')->setParameter(':idBrand', $brandId); } return $qb->getQuery()->getSingleScalarResult(); }