From 17069cf550a524f9d739e840dfcc4a090421c962 Mon Sep 17 00:00:00 2001 From: tracer Date: Mon, 11 Apr 2022 17:52:46 +0200 Subject: [PATCH] refactored --- src/Controller/Admin/DashboardController.php | 30 +++++++++----------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Controller/Admin/DashboardController.php b/src/Controller/Admin/DashboardController.php index 5f15437..d94bb03 100644 --- a/src/Controller/Admin/DashboardController.php +++ b/src/Controller/Admin/DashboardController.php @@ -2,42 +2,40 @@ namespace App\Controller\Admin; -use App\Entity\Section; +use App\Entity\Projects; +use App\Entity\Quotes; +use App\Entity\User; use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard; use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -use App\Entity\User; -use App\Entity\Blog; -use App\Entity\Comment; - /** - * Class DashboardController - * @package App\Controller\Admin + * */ class DashboardController extends AbstractDashboardController { - #[Route('/admin', name: 'admin')] + #[isGranted(data: 'ROLE_ADMIN')] + #[Route(path: '/admin', name: 'admin')] public function index(): Response { - return parent::index(); + //return parent::index(); + return $this->render(view: 'admin/index.html.twig'); } public function configureDashboard(): Dashboard { return Dashboard::new() - ->setTitle('24unix'); + ->setTitle(title: '24unix Admin'); } public function configureMenuItems(): iterable { - yield MenuItem::linktoRoute('Back to the website', 'fas fa-home', 'blogs'); - yield MenuItem::linktoDashboard('Dashboard', 'fas fa-tachometer-alt'); - yield MenuItem::linkToCrud('User', 'fas fa-user', User::class); - yield MenuItem::linkToCrud('Sections', 'fas fa-book', Section::class); - yield MenuItem::linkToCrud('Blogs', 'fas fa-blog', Blog::class); - yield MenuItem::linkToCrud('Comments', 'fas fa-comments', Comment::class); + yield MenuItem::linkToDashboard(label: 'Dashboard', icon: 'fa fa-dashboard'); + yield MenuItem::linkToCrud(label: 'Projects', icon: 'fa fa-file-code-o', entityFqcn: Projects::class); + yield MenuItem::linkToCrud(label: 'Users', icon: 'fa fa-users', entityFqcn: User::class); + yield MenuItem::linkToCrud(label: 'Quotes', icon: 'fa fa-quote-left', entityFqcn: Quotes::class); } }