/** * @ApiDoc( * description="Restaurant wished array of id", * statusCodes={200="Restaurant"}, * section="Restaurant", * filters={ * {"name"="user", "dataType"="integer", "required"=true} * }) * @Route("/api/restaurants/wished/ids") * @Cache(maxage="+1 week", public=true) * @Method({"GET"}) * @throws BadRequestException * @return View */ public function getWishedAction() { $request = $this->requestStack->getCurrentRequest(); $userId = $request->query->get('user'); if (!$userId) { throw new BadRequestException(); } $restaurants = $this->wishRepository->getWishesIdsOf($userId); $this->cacheManager->tagController($request, CacheTag::WISH); return $this->view(array('restaurants' => $restaurants)); }
protected function getRestaurantsIds(Request $request) { $reviewedBy = $request->query->get('reviewedBy'); $wishedBy = $request->query->get('wishedBy'); $results = array(); if ($reviewedBy && $wishedBy) { $wishedRestaurants = $this->wishRepository->getWishesIdsOf($wishedBy); $reviewedRestaurants = $this->reviewRepository->getReviewsIdsOf($reviewedBy); $results = array_unique(array_merge($wishedRestaurants, $reviewedRestaurants)); } else { if ($reviewedBy) { $results = $this->reviewRepository->getReviewsIdsOf($reviewedBy); } else { if ($wishedBy) { $results = $this->wishRepository->getWishesIdsOf($wishedBy); } } } return $results; }