|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Controller\Admin; |
| 4 | + |
| 5 | +use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard; |
| 6 | +use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; |
| 7 | +use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController; |
| 8 | +use Symfony\Component\HttpFoundation\Response; |
| 9 | +use Symfony\Component\Routing\Attribute\Route; |
| 10 | + |
| 11 | +class DashboardController extends AbstractDashboardController |
| 12 | +{ |
| 13 | + #[Route('/admin', name: 'admin')] |
| 14 | + public function index(): Response |
| 15 | + { |
| 16 | + return parent::index(); |
| 17 | + |
| 18 | + // Option 1. You can make your dashboard redirect to some common page of your backend |
| 19 | + // |
| 20 | + // $adminUrlGenerator = $this->container->get(AdminUrlGenerator::class); |
| 21 | + // return $this->redirect($adminUrlGenerator->setController(OneOfYourCrudController::class)->generateUrl()); |
| 22 | + |
| 23 | + // Option 2. You can make your dashboard redirect to different pages depending on the user |
| 24 | + // |
| 25 | + // if ('jane' === $this->getUser()->getUsername()) { |
| 26 | + // return $this->redirect('...'); |
| 27 | + // } |
| 28 | + |
| 29 | + // Option 3. You can render some custom template to display a proper dashboard with widgets, etc. |
| 30 | + // (tip: it's easier if your template extends from @EasyAdmin/page/content.html.twig) |
| 31 | + // |
| 32 | + // return $this->render('some/path/my-dashboard.html.twig'); |
| 33 | + } |
| 34 | + |
| 35 | + public function configureDashboard(): Dashboard |
| 36 | + { |
| 37 | + return Dashboard::new() |
| 38 | + ->setTitle('Function Php8'); |
| 39 | + } |
| 40 | + |
| 41 | + public function configureMenuItems(): iterable |
| 42 | + { |
| 43 | + yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home'); |
| 44 | + // yield MenuItem::linkToCrud('The Label', 'fas fa-list', EntityClass::class); |
| 45 | + } |
| 46 | +} |
0 commit comments