Added class with listCases initial method
This commit is contained in:
		
							
								
								
									
										69
									
								
								src/Controller/CaseController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								src/Controller/CaseController.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,69 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Controller;
 | 
			
		||||
 | 
			
		||||
use App\Entity\MemberCase;
 | 
			
		||||
use App\Entity\User;
 | 
			
		||||
use App\Form\MemberCaseFormType;
 | 
			
		||||
use App\Libs\NavList;
 | 
			
		||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
use Symfony\Component\Routing\Attribute\Route;
 | 
			
		||||
use Symfony\Component\Security\Http\Attribute\CurrentUser;
 | 
			
		||||
 | 
			
		||||
class CaseController extends AbstractController
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private array $navLinks = []
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->navLinks = NavList::LIST;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[Route('/list-cases', name: 'app_list_cases')]
 | 
			
		||||
    public function listCases(#[CurrentUser()] User $user): Response
 | 
			
		||||
    {
 | 
			
		||||
        $this->denyAccessUnlessGranted('ROLE_ADMIN');
 | 
			
		||||
 | 
			
		||||
        $this->navLinks['case_list'] = 'nav-link text-white active bg-gradient-dark';
 | 
			
		||||
 | 
			
		||||
        return $this->render(
 | 
			
		||||
            'internal/cases/case-list.html.twig',
 | 
			
		||||
            array_merge(
 | 
			
		||||
                $this->navLinks,
 | 
			
		||||
                [
 | 
			
		||||
                    'breadcrumbs' => [
 | 
			
		||||
                        'List Cases'
 | 
			
		||||
                    ],
 | 
			
		||||
                    'notifications' => $user->retrieveUnreadNotifications(),
 | 
			
		||||
                ]
 | 
			
		||||
            )
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[Route('/add-case', name: 'app_case')]
 | 
			
		||||
    public function addCase(#[CurrentUser()] User $admin): Response
 | 
			
		||||
    {
 | 
			
		||||
        $this->denyAccessUnlessGranted('ROLE_ADMIN');
 | 
			
		||||
 | 
			
		||||
        $this->navLinks['case_list'] = 'nav-link text-white active bg-gradient-dark';
 | 
			
		||||
 | 
			
		||||
        $case = new MemberCase();
 | 
			
		||||
        $form = $this->createForm(MemberCaseFormType::class, $case);
 | 
			
		||||
 | 
			
		||||
        return $this->render(
 | 
			
		||||
            'internal/admin/cases/add-case.html.twig',
 | 
			
		||||
            array_merge(
 | 
			
		||||
                $this->navLinks,
 | 
			
		||||
                [
 | 
			
		||||
                    'title' => 'Add Case',
 | 
			
		||||
                    'breadcrumbs' => [
 | 
			
		||||
                        'Case',
 | 
			
		||||
                        'Add Case'
 | 
			
		||||
                    ],
 | 
			
		||||
                    'notifications' => $admin->retrieveUnreadNotifications(),
 | 
			
		||||
                    'form' => $form,
 | 
			
		||||
                ]
 | 
			
		||||
            )
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user