From bcbd0575b621ffaa49a4ca5f36461ba1f83cde00 Mon Sep 17 00:00:00 2001 From: Ryan Prather Date: Tue, 10 Dec 2024 12:21:33 -0500 Subject: [PATCH] Add flash messages and convert to use Breadcrumb class --- src/Controller/MemberController.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Controller/MemberController.php b/src/Controller/MemberController.php index b485392..b5319f8 100644 --- a/src/Controller/MemberController.php +++ b/src/Controller/MemberController.php @@ -6,6 +6,7 @@ use App\Entity\Member; use App\Entity\User; use App\Entity\MemberCase; use App\Form\MemberFormType; +use App\Libs\Breadcrumb; use App\Libs\NavList; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -35,8 +36,8 @@ class MemberController extends AbstractController $this->navLinks, [ 'breadcrumbs' => [ - 'Case', - 'Members' + new Breadcrumb($this->generateUrl('app_case_list'), 'List Cases'), + new Breadcrumb($this->generateUrl('app_case_members', ['id' => $id]), 'List Members'), ], 'notifications' => $user->retrieveUnreadNotifications(), 'case' => $case, @@ -90,6 +91,11 @@ class MemberController extends AbstractController $this->entityManager->persist($member); $this->entityManager->flush(); + $this->addFlash( + 'success', + 'Member added successfully' + ); + return $this->redirectToRoute('app_case_members', ['id' => $case->getId()]); } @@ -99,9 +105,9 @@ class MemberController extends AbstractController $this->navLinks, [ 'breadcrumbs' => [ - 'Case', - 'Members', - 'Add Member' + new Breadcrumb($this->generateUrl('app_case_list'), 'List Cases'), + new Breadcrumb($this->generateUrl('app_case_members', ['id' => $id]), 'List Members'), + new Breadcrumb($this->generateUrl('app_case_add_member', ['id' => $id]), 'Add Member'), ], 'notifications' => $user->retrieveUnreadNotifications(), 'case' => $case, @@ -150,6 +156,11 @@ class MemberController extends AbstractController $this->entityManager->flush(); + $this->addFlash( + 'success', + 'Member updated successfully' + ); + return $this->redirectToRoute('app_case_members', ['id' => $caseId]); } @@ -159,9 +170,9 @@ class MemberController extends AbstractController $this->navLinks, [ 'breadcrumbs' => [ - 'Case', - 'Members', - 'Edit Member' + new Breadcrumb($this->generateUrl('app_case_list'), 'List Cases'), + new Breadcrumb($this->generateUrl('app_case_members', ['id' => $caseId]), 'List Members'), + new Breadcrumb($this->generateUrl('app_case_edit_member', ['caseId' => $caseId, 'memberId' => $memberId]), 'Edit Member'), ], 'notifications' => $user->retrieveUnreadNotifications(), 'member' => $member,