Filter case list if not admin
Convert to use NavList::PRESENT_LINK constant
This commit is contained in:
parent
9fc84a85e9
commit
5975785580
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use App\Entity\MemberCase;
|
use App\Entity\MemberCase;
|
||||||
use App\Entity\ReferralSource;
|
use App\Entity\ReferralSource;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
@ -25,16 +24,22 @@ class CaseController extends AbstractController
|
|||||||
private array $navLinks = []
|
private array $navLinks = []
|
||||||
) {
|
) {
|
||||||
$this->navLinks = NavList::LIST;
|
$this->navLinks = NavList::LIST;
|
||||||
|
$this->navLinks['case_list'] = NavList::PRESENT_LINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/list-cases', name: 'app_list_cases')]
|
#[Route('/list-cases', name: 'app_list_cases')]
|
||||||
public function listCases(#[CurrentUser()] User $user): Response
|
public function listCases(#[CurrentUser()] User $user): Response
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
if($this->isGranted('ROLE_ADMIN')) {
|
||||||
|
|
||||||
$this->navLinks['case_list'] = 'nav-link text-white active bg-gradient-dark';
|
|
||||||
|
|
||||||
$cases = $this->entityManager->getRepository(MemberCase::class)->findAll();
|
$cases = $this->entityManager->getRepository(MemberCase::class)->findAll();
|
||||||
|
} else {
|
||||||
|
$ucs = $this->entityManager->getRepository(UserCase::class)->findBy(['user' => $user]);
|
||||||
|
$cases = [];
|
||||||
|
foreach ($ucs as $uc) {
|
||||||
|
/** @var UserCase $uc */
|
||||||
|
$cases[] = $uc->getMemberCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
$workers = $this->entityManager->getRepository(User::class)->getCaseWorkers();
|
$workers = $this->entityManager->getRepository(User::class)->getCaseWorkers();
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
@ -58,8 +63,6 @@ class CaseController extends AbstractController
|
|||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
||||||
|
|
||||||
$this->navLinks['case_list'] = 'nav-link text-white active bg-gradient-dark';
|
|
||||||
|
|
||||||
$case = new MemberCase();
|
$case = new MemberCase();
|
||||||
$form = $this->createForm(MemberCaseFormType::class, $case);
|
$form = $this->createForm(MemberCaseFormType::class, $case);
|
||||||
|
|
||||||
@ -98,7 +101,6 @@ class CaseController extends AbstractController
|
|||||||
public function editCase(Request $request, #[CurrentUser()] User $admin, string $id): Response
|
public function editCase(Request $request, #[CurrentUser()] User $admin, string $id): Response
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
||||||
$this->navLinks['case_list'] = 'nav-link text-white active bg-gradient-dark';
|
|
||||||
|
|
||||||
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
|
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
|
||||||
$form = $this->createForm(MemberCaseFormType::class, $case);
|
$form = $this->createForm(MemberCaseFormType::class, $case);
|
||||||
@ -137,7 +139,6 @@ class CaseController extends AbstractController
|
|||||||
public function assignCase(string $id, Request $request, #[CurrentUser()] User $admin): Response
|
public function assignCase(string $id, Request $request, #[CurrentUser()] User $admin): Response
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
||||||
$this->navLinks['case_list'] = 'nav-link text-white active bg-gradient-dark';
|
|
||||||
|
|
||||||
$caseWorkers = $this->entityManager->getRepository(User::class)->getCaseWorkers();
|
$caseWorkers = $this->entityManager->getRepository(User::class)->getCaseWorkers();
|
||||||
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
|
$case = $this->entityManager->getRepository(MemberCase::class)->find($id);
|
||||||
|
Loading…
Reference in New Issue
Block a user