Loading src/Controller/NewsController.php +12 −7 Original line number Diff line number Diff line Loading @@ -20,29 +20,34 @@ class NewsController extends AbstractController #[Route('/news', name: 'news', methods: ['GET'])] public function news(NewsListRequest $request): Response { return $this->json($this->newsService->getNewsByRequest($request)); return $this->json( $this->newsService->getNewsByRequest($request) ); } #[Route('/news/mainNews', name: 'mainNews', methods: ['GET'])] public function mainNews(): Response { $mainNews = $this->newsService->getMainNews(); return $this->json($mainNews); return $this->json( $this->newsService->getMainNews() ); } #[Route('/news/search', name: 'newsSearch', methods: ['GET'])] public function newsSearch(): Response { $newsSearch = $this->newsService->getNewsSearch(); return $this->json($newsSearch); return $this->json( $this->newsService->getNewsSearch() ); } #[Route('/news/{newsId}', name: 'newsOne', methods: ['GET'])] public function newsOne(Request $request): Response { try { $news = $this->newsService->getNewsOneByRequest($request); return $this->json($news); return $this->json( $this->newsService->getNewsOneByRequest($request) ); } catch (NewsNotFoundException $e) { return $this->json([ 'success' => false, Loading src/Controller/RestaurantController.php +4 −4 Original line number Diff line number Diff line Loading @@ -20,17 +20,17 @@ class RestaurantController extends AbstractController #[Route('/restaurants', name: 'restaurants', methods: ['GET'])] public function restaurants(RestaurantListRequest $request): Response { return $this->json($this->restaurantService->getRestaurantsByRequest($request)); return $this->json( $this->restaurantService->getRestaurantsByRequest($request) ); } #[Route('/restaurants/{restaurantId}', name: 'restaurant', methods: ['GET'])] public function restaurant(Request $request): Response { try { return new Response( return $this->json( $this->restaurantService->getRestaurantByRequest($request), Response::HTTP_OK, ['Content-Type' => 'application/json'] ); } catch (RestaurantNotFoundException $e) { return $this->json([ Loading src/Mapper/NewsMapper.php +3 −2 Original line number Diff line number Diff line Loading @@ -65,8 +65,9 @@ class NewsMapper ); } public static function mapToNewsCategory(NewsCategory $newsCategory): NewsCategoryModel { public static function mapToNewsCategory( NewsCategory $newsCategory ): NewsCategoryModel { return new NewsCategoryModel( $newsCategory->getId(), $newsCategory->getName(), Loading src/Mapper/RestaurantMapper.php +14 −10 Original line number Diff line number Diff line Loading @@ -53,8 +53,9 @@ class RestaurantMapper ); } public static function mapToListElement(Restaurant $restaurant): RestaurantListingElement { public static function mapToListElement( Restaurant $restaurant ): RestaurantListingElement { return new RestaurantListingElement( $restaurant->getId(), $restaurant->getName(), Loading @@ -66,8 +67,10 @@ class RestaurantMapper ); } public static function mapToDetailElement(Restaurant $restaurant, Collection $gallery): RestaurantDetailElement { public static function mapToDetailElement( Restaurant $restaurant, Collection $gallery ): RestaurantDetailElement { return new RestaurantDetailElement( $restaurant->getId(), $restaurant->getName(), Loading Loading @@ -100,8 +103,9 @@ class RestaurantMapper ); } public static function mapToRestaurantType(RestaurantType $restaurantType): RestaurantTypeModel { public static function mapToRestaurantType( RestaurantType $restaurantType ): RestaurantTypeModel { return new RestaurantTypeModel( $restaurantType->getId(), $restaurantType->getName(), Loading src/Repository/RestaurantRepository.php +5 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ class RestaurantRepository extends ServiceEntityRepository implements Restaurant ): array { $query = $this->createQueryBuilder('r'); $query->select('r'); if ($restaurantTypeId !== null) { $query->andWhere('r.typeId = :restaurantTypeId') ->setParameter('restaurantTypeId', $restaurantTypeId); Loading @@ -40,8 +41,10 @@ class RestaurantRepository extends ServiceEntityRepository implements Restaurant ->andWhere('k.id = :kitchenId') ->setParameter('kitchenId', $kitchenId); } $query->setMaxResults($limit) ->setFirstResult(($page - 1) * $limit); return $query->getQuery()->getResult(); } Loading Loading
src/Controller/NewsController.php +12 −7 Original line number Diff line number Diff line Loading @@ -20,29 +20,34 @@ class NewsController extends AbstractController #[Route('/news', name: 'news', methods: ['GET'])] public function news(NewsListRequest $request): Response { return $this->json($this->newsService->getNewsByRequest($request)); return $this->json( $this->newsService->getNewsByRequest($request) ); } #[Route('/news/mainNews', name: 'mainNews', methods: ['GET'])] public function mainNews(): Response { $mainNews = $this->newsService->getMainNews(); return $this->json($mainNews); return $this->json( $this->newsService->getMainNews() ); } #[Route('/news/search', name: 'newsSearch', methods: ['GET'])] public function newsSearch(): Response { $newsSearch = $this->newsService->getNewsSearch(); return $this->json($newsSearch); return $this->json( $this->newsService->getNewsSearch() ); } #[Route('/news/{newsId}', name: 'newsOne', methods: ['GET'])] public function newsOne(Request $request): Response { try { $news = $this->newsService->getNewsOneByRequest($request); return $this->json($news); return $this->json( $this->newsService->getNewsOneByRequest($request) ); } catch (NewsNotFoundException $e) { return $this->json([ 'success' => false, Loading
src/Controller/RestaurantController.php +4 −4 Original line number Diff line number Diff line Loading @@ -20,17 +20,17 @@ class RestaurantController extends AbstractController #[Route('/restaurants', name: 'restaurants', methods: ['GET'])] public function restaurants(RestaurantListRequest $request): Response { return $this->json($this->restaurantService->getRestaurantsByRequest($request)); return $this->json( $this->restaurantService->getRestaurantsByRequest($request) ); } #[Route('/restaurants/{restaurantId}', name: 'restaurant', methods: ['GET'])] public function restaurant(Request $request): Response { try { return new Response( return $this->json( $this->restaurantService->getRestaurantByRequest($request), Response::HTTP_OK, ['Content-Type' => 'application/json'] ); } catch (RestaurantNotFoundException $e) { return $this->json([ Loading
src/Mapper/NewsMapper.php +3 −2 Original line number Diff line number Diff line Loading @@ -65,8 +65,9 @@ class NewsMapper ); } public static function mapToNewsCategory(NewsCategory $newsCategory): NewsCategoryModel { public static function mapToNewsCategory( NewsCategory $newsCategory ): NewsCategoryModel { return new NewsCategoryModel( $newsCategory->getId(), $newsCategory->getName(), Loading
src/Mapper/RestaurantMapper.php +14 −10 Original line number Diff line number Diff line Loading @@ -53,8 +53,9 @@ class RestaurantMapper ); } public static function mapToListElement(Restaurant $restaurant): RestaurantListingElement { public static function mapToListElement( Restaurant $restaurant ): RestaurantListingElement { return new RestaurantListingElement( $restaurant->getId(), $restaurant->getName(), Loading @@ -66,8 +67,10 @@ class RestaurantMapper ); } public static function mapToDetailElement(Restaurant $restaurant, Collection $gallery): RestaurantDetailElement { public static function mapToDetailElement( Restaurant $restaurant, Collection $gallery ): RestaurantDetailElement { return new RestaurantDetailElement( $restaurant->getId(), $restaurant->getName(), Loading Loading @@ -100,8 +103,9 @@ class RestaurantMapper ); } public static function mapToRestaurantType(RestaurantType $restaurantType): RestaurantTypeModel { public static function mapToRestaurantType( RestaurantType $restaurantType ): RestaurantTypeModel { return new RestaurantTypeModel( $restaurantType->getId(), $restaurantType->getName(), Loading
src/Repository/RestaurantRepository.php +5 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ class RestaurantRepository extends ServiceEntityRepository implements Restaurant ): array { $query = $this->createQueryBuilder('r'); $query->select('r'); if ($restaurantTypeId !== null) { $query->andWhere('r.typeId = :restaurantTypeId') ->setParameter('restaurantTypeId', $restaurantTypeId); Loading @@ -40,8 +41,10 @@ class RestaurantRepository extends ServiceEntityRepository implements Restaurant ->andWhere('k.id = :kitchenId') ->setParameter('kitchenId', $kitchenId); } $query->setMaxResults($limit) ->setFirstResult(($page - 1) * $limit); return $query->getQuery()->getResult(); } Loading