fix hydration issues in favorites (#5068)
This commit is contained in:
@@ -32,7 +32,7 @@ final class FavoriteController extends AbstractController
|
|||||||
{
|
{
|
||||||
$favoriteRecordService->addFavorite($timesheet);
|
$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'])]
|
#[Route(path: '/timesheet/remove/{id}', name: 'favorites_timesheets_remove', methods: ['GET'])]
|
||||||
@@ -41,6 +41,6 @@ final class FavoriteController extends AbstractController
|
|||||||
{
|
{
|
||||||
$favoriteRecordService->removeFavorite($timesheet);
|
$favoriteRecordService->removeFavorite($timesheet);
|
||||||
|
|
||||||
return $this->render('favorite/index.html.twig');
|
return $this->redirectToRoute('favorites_timesheets');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,11 +112,11 @@ final class FavoriteRecordService
|
|||||||
public function removeFavorite(Timesheet $timesheet): void
|
public function removeFavorite(Timesheet $timesheet): void
|
||||||
{
|
{
|
||||||
if ($timesheet->getUser() === null) {
|
if ($timesheet->getUser() === null) {
|
||||||
throw new \InvalidArgumentException('Cannot favorite timesheet without user');
|
throw new \InvalidArgumentException('Cannot remove favorite without user');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($timesheet->getId() === null) {
|
if ($timesheet->getId() === null) {
|
||||||
throw new \InvalidArgumentException('Cannot favorite unsaved timesheet');
|
throw new \InvalidArgumentException('Cannot remove unsaved favorite');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->removeFavoriteById($timesheet->getUser(), $timesheet->getId());
|
$this->removeFavoriteById($timesheet->getUser(), $timesheet->getId());
|
||||||
|
|||||||
Reference in New Issue
Block a user