Add flash messages and convert to use Breadcrumb class

This commit is contained in:
Ryan Prather 2024-12-10 12:21:55 -05:00
parent bcbd0575b6
commit 94a7a324a1
2 changed files with 14 additions and 8 deletions

View File

@ -5,6 +5,7 @@ namespace App\Controller;
use App\Entity\ReferralSource; use App\Entity\ReferralSource;
use App\Entity\User; use App\Entity\User;
use App\Form\ReferralSourceFormType; use App\Form\ReferralSourceFormType;
use App\Libs\Breadcrumb;
use App\Libs\NavList; use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -38,7 +39,7 @@ class ReferralSourceController extends AbstractController
'sources' => $sources, 'sources' => $sources,
'notifications' => $user->retrieveUnreadNotifications(), 'notifications' => $user->retrieveUnreadNotifications(),
'breadcrumbs' => [ 'breadcrumbs' => [
'Referral Sources' new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources')
] ]
] ]
) )
@ -62,6 +63,8 @@ class ReferralSourceController extends AbstractController
$this->entityManager->persist($rs); $this->entityManager->persist($rs);
$this->entityManager->flush(); $this->entityManager->flush();
$this->addFlash('success', 'Referral Source added');
return $this->redirectToRoute('app_referral_source'); return $this->redirectToRoute('app_referral_source');
} }
@ -73,8 +76,8 @@ class ReferralSourceController extends AbstractController
'form' => $form, 'form' => $form,
'notifications' => $user->retrieveUnreadNotifications(), 'notifications' => $user->retrieveUnreadNotifications(),
'breadcrumbs' => [ 'breadcrumbs' => [
'Referral Sources', new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources'),
'Add Source' new Breadcrumb($this->generateUrl('app_add_source'), 'Add Source')
] ]
] ]
) )
@ -96,9 +99,10 @@ class ReferralSourceController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$rs = $form->getData(); $rs = $form->getData();
$this->entityManager->persist($rs);
$this->entityManager->flush(); $this->entityManager->flush();
$this->addFlash('success', 'Referral Source Updated');
return $this->redirectToRoute('app_referral_source'); return $this->redirectToRoute('app_referral_source');
} }
@ -108,10 +112,11 @@ class ReferralSourceController extends AbstractController
$this->navList, $this->navList,
[ [
'form' => $form, 'form' => $form,
'rs' => $rs,
'notifications' => $user->retrieveUnreadNotifications(), 'notifications' => $user->retrieveUnreadNotifications(),
'breadcrumbs' => [ 'breadcrumbs' => [
'Referral Sources', new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources'),
'Edit Source' new Breadcrumb($this->generateUrl('app_edit_source', ['id' => $id]), 'Edit Source')
] ]
] ]
) )

View File

@ -3,6 +3,7 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\User; use App\Entity\User;
use App\Libs\Breadcrumb;
use App\Libs\NavList; use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -21,7 +22,7 @@ class StaffController extends AbstractController
$this->navLinks = NavList::LIST; $this->navLinks = NavList::LIST;
} }
#[Route('/staff-dashboard', name: 'staff')] #[Route('/staff-dashboard', name: 'app_staff_dashboard')]
public function staffDashboard(#[CurrentUser()] User $user): Response public function staffDashboard(#[CurrentUser()] User $user): Response
{ {
$this->navLinks['staff_dashboard'] = 'nav-link text-white active bg-gradient-dark'; $this->navLinks['staff_dashboard'] = 'nav-link text-white active bg-gradient-dark';
@ -32,7 +33,7 @@ class StaffController extends AbstractController
$this->navLinks, $this->navLinks,
[ [
'breadcrumbs' => [ 'breadcrumbs' => [
'Staff Dashboard' new Breadcrumb('', 'Staff Dashboard')
], ],
'notifications' => $user->retrieveUnreadNotifications(), 'notifications' => $user->retrieveUnreadNotifications(),
] ]