/**
  * @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));
 }
 /**
  * @param integer $id
  *
  * @ApiDoc(
  *  description="Delete Wish",
  *  statusCodes={204="Wish Deleted"},
  *  section="Wish")
  * @Route("/api/wishes/{id}")
  * @Method({"DELETE"})
  * @return View
  */
 public function deleteAction($id)
 {
     $user = $this->getUser();
     $wish = $this->wishRepository->get($id);
     $this->securityCheck(Permission::WRITE, $wish);
     $this->entityManager->remove($wish);
     $user->decrementWishesCount();
     $this->entityManager->flush();
     $this->dispatch(ApiEvent::WISH_DELETED, new WishDeletedEvent($wish));
     $this->cacheManager->invalidateOnDelete($wish);
     return $this->view(array(), 204);
 }
 /**
  * @return View
  * @throws AccessDeniedException
  */
 private function getWishList()
 {
     $request = $this->requestStack->getCurrentRequest();
     $user = (int) $this->requestStack->getCurrentRequest()->query->get('user');
     $groupBy = $this->requestStack->getCurrentRequest()->query->get('groupBy');
     if ($user !== $this->getUser()->getId()) {
         throw new AccessDeniedException();
     }
     $expertiseList = $this->wishRepository->getExpertiseByUser($user, $groupBy);
     $this->cacheManager->tagController($request, CacheTag::WISH);
     return $this->view(array('expertise' => $expertiseList));
 }
 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;
 }