src/Controller/Admin/DashboardController.php line 17

  1. <?php
  2. namespace App\Controller\Admin;
  3. use App\Entity\Categorie;
  4. use App\Entity\Web;
  5. use App\Entity\Book;
  6. use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
  7. use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
  8. use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. class DashboardController extends AbstractDashboardController
  12. {
  13.     #[Route('/admin'name'admin')]
  14.     public function index(): Response
  15.     {
  16.         return $this->render('admin/index.html.twig');
  17.         // Option 1. You can make your dashboard redirect to some common page of your backend
  18.         //
  19. //         $adminUrlGenerator = $this->container->get(AdminUrlGenerator::class);
  20. //         return $this->redirect($adminUrlGenerator->setController(OneOfYourCrudController::class)->generateUrl());
  21.         // Option 2. You can make your dashboard redirect to different pages depending on the user
  22.         //
  23.         // if ('jane' === $this->getUser()->getUsername()) {
  24.         //     return $this->redirect('...');
  25.         // }
  26.         // Option 3. You can render some custom template to display a proper dashboard with widgets, etc.
  27.         // (tip: it's easier if your template extends from @EasyAdmin/page/content.html.twig)
  28.         //
  29.         // return $this->render('some/path/my-dashboard.html.twig');
  30.     }
  31.     public function configureDashboard(): Dashboard
  32.     {
  33.         return Dashboard::new()
  34.             ->setTitle('Fpcrea');
  35.     }
  36.     public function configureMenuItems(): iterable
  37.     {
  38.         return [
  39.             MenuItem::linkToDashboard('Dashboard''fa fa-home'),
  40.             MenuItem::section('Catégories'),
  41.             MenuItem::linkToCrud('Categories''fa fa-list'Categorie::class),
  42.             MenuItem::linkToCrud('Ajouter catégorie''fa fa-file-text'Categorie::class)->setAction('new'),
  43.             MenuItem::section('Book'),
  44.             MenuItem::linkToCrud('Book''fa fa-list'Book::class),
  45.             MenuItem::linkToCrud('Ajouter un élément Book''fa fa-file-text'Book::class)->setAction('new'),
  46. //
  47.             MenuItem::section('Web'),
  48.             MenuItem::linkToCrud('Web''fa fa-list'Web::class),
  49.             MenuItem::linkToCrud('Ajouter un élément Web''fa fa-file-text'Web::class)->setAction('new'),
  50.         ];
  51.     }
  52. }