From 036b297a769298ca3bd687ade3bc2bef7d2751b4 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Fri, 20 Sep 2024 22:43:16 +0200 Subject: [PATCH] fix hydration issues in favorites (#5068) --- src/Controller/FavoriteController.php | 4 ++-- src/Timesheet/FavoriteRecordService.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Controller/FavoriteController.php b/src/Controller/FavoriteController.php index 34bab3f4..68cd3f97 100644 --- a/src/Controller/FavoriteController.php +++ b/src/Controller/FavoriteController.php @@ -32,7 +32,7 @@ final class FavoriteController extends AbstractController { $favoriteRecordService->addFavorite($timesheet); - return $this->render('favorite/index.html.twig'); + return $this->redirectToRoute('favorites_timesheets'); } #[Route(path: '/timesheet/remove/{id}', name: 'favorites_timesheets_remove', methods: ['GET'])] @@ -41,6 +41,6 @@ final class FavoriteController extends AbstractController { $favoriteRecordService->removeFavorite($timesheet); - return $this->render('favorite/index.html.twig'); + return $this->redirectToRoute('favorites_timesheets'); } } diff --git a/src/Timesheet/FavoriteRecordService.php b/src/Timesheet/FavoriteRecordService.php index 51742206..07531fd0 100644 --- a/src/Timesheet/FavoriteRecordService.php +++ b/src/Timesheet/FavoriteRecordService.php @@ -112,11 +112,11 @@ final class FavoriteRecordService public function removeFavorite(Timesheet $timesheet): void { if ($timesheet->getUser() === null) { - throw new \InvalidArgumentException('Cannot favorite timesheet without user'); + throw new \InvalidArgumentException('Cannot remove favorite without user'); } if ($timesheet->getId() === null) { - throw new \InvalidArgumentException('Cannot favorite unsaved timesheet'); + throw new \InvalidArgumentException('Cannot remove unsaved favorite'); } $this->removeFavoriteById($timesheet->getUser(), $timesheet->getId());