Added messages, notifications, count, and supporting elements

This commit is contained in:
2024-12-22 01:13:28 +00:00
parent 2b8682bcbb
commit 6b61d1a182
14 changed files with 593 additions and 33 deletions

View File

@ -2,6 +2,7 @@
namespace App\Controller;
use App\Entity\Messages;
use App\Entity\ReferralSource;
use App\Entity\User;
use App\Form\ReferralSourceFormType;
@ -16,6 +17,15 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
class ReferralSourceController extends AbstractController
{
/**
* Variable to store unread notification messages
*
* @var array
*/
private array $msgs;
private int $notificationCount;
public function __construct(
private EntityManagerInterface $entityManager,
private array $navList = []
@ -28,6 +38,8 @@ class ReferralSourceController extends AbstractController
public function listReferralSources(#[CurrentUser()] User $user): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$sources = $this->entityManager->getRepository(ReferralSource::class)->retrieveOrderedList();
@ -37,7 +49,8 @@ class ReferralSourceController extends AbstractController
$this->navList,
[
'sources' => $sources,
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources')
]
@ -50,6 +63,8 @@ class ReferralSourceController extends AbstractController
public function addSource(Request $request, #[CurrentUser()] User $user): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$rs = new ReferralSource();
$form = $this->createForm(ReferralSourceFormType::class, $rs);
@ -73,7 +88,8 @@ class ReferralSourceController extends AbstractController
$this->navList,
[
'form' => $form,
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources'),
new Breadcrumb($this->generateUrl('app_add_source'), 'Add Source')
@ -87,6 +103,8 @@ class ReferralSourceController extends AbstractController
public function editSource(Request $request, #[CurrentUser()] User $user, string $id): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
$rs = $this->entityManager->getRepository(ReferralSource::class)->find($id);
@ -111,7 +129,8 @@ class ReferralSourceController extends AbstractController
[
'form' => $form,
'rs' => $rs,
'notifications' => $user->retrieveUnreadNotifications(),
'notifications' => $this->msgs,
'notificationCount' => $this->notificationCount,
'breadcrumbs' => [
new Breadcrumb($this->generateUrl('app_referral_source'), 'Referral Sources'),
new Breadcrumb($this->generateUrl('app_edit_source', ['id' => $id]), 'Edit Source')