src/Controller/Admin/DashboardController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use App\Entity\Local;
  4. use App\Entity\Player;
  5. use App\Entity\User;
  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 parent::index();
  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.         if (!$this->getUser()) {
  30.             return $this->redirectToRoute('app_login');
  31.         }
  32.         return $this->render('admin/dashboard.html.twig');
  33.     }
  34.     public function configureDashboard(): Dashboard
  35.     {
  36.         return Dashboard::new()
  37.             // the name visible to end users
  38.             ->setTitle('014 Soportes')
  39.             // you can include HTML contents too (e.g. to link to an image)
  40. //            ->setTitle('<img src="..."> ACME <span class="text-small">Corp.</span>')
  41.             // by default EasyAdmin displays a black square as its default favicon;
  42.             // use this method to display a custom favicon: the given path is passed
  43.             // "as is" to the Twig asset() function:
  44.             // <link rel="shortcut icon" href="{{ asset('...') }}">
  45.             ->setFaviconPath('favicon.svg')
  46.             // the domain used by default is 'messages'
  47. //            ->setTranslationDomain('my-custom-domain')
  48.             // there's no need to define the "text direction" explicitly because
  49.             // its default value is inferred dynamically from the user locale
  50.             ->setTextDirection('ltr')
  51.             // set this option if you prefer the page content to span the entire
  52.             // browser width, instead of the default design which sets a max width
  53.             ->renderContentMaximized()
  54.             // set this option if you prefer the sidebar (which contains the main menu)
  55.             // to be displayed as a narrow column instead of the default expanded design
  56. //            ->renderSidebarMinimized()
  57.             // by default, users can select between a "light" and "dark" mode for the
  58.             // backend interface. Call this method if you prefer to disable the "dark"
  59.             // mode for any reason (e.g. if your interface customizations are not ready for it)
  60. //            ->disableDarkMode()
  61.             // by default, all backend URLs are generated as absolute URLs. If you
  62.             // need to generate relative URLs instead, call this method
  63.             ->generateRelativeUrls()
  64.             // set this option if you want to enable locale switching in dashboard.
  65.             // IMPORTANT: this feature won't work unless you add the {_locale}
  66.             // parameter in the admin dashboard URL (e.g. '/admin/{_locale}').
  67.             // the name of each locale will be rendered in that locale
  68.             // (in the following example you'll see: "English", "Polski")
  69. //            ->setLocales(['en', 'pl'])
  70.             // to customize the labels of locales, pass a key => value array
  71.             // (e.g. to display flags; although it's not a recommended practice,
  72.             // because many languages/locales are not associated to a single country)
  73. //            ->setLocales([
  74. //                'en' => '🇬🇧 English',
  75. //                'pl' => '🇵🇱 Polski'
  76. //            ])
  77.             // to further customize the locale option, pass an instance of
  78.             // EasyCorp\Bundle\EasyAdminBundle\Config\Locale
  79. //            ->setLocales([
  80. //                'en', // locale without custom options
  81. //                Locale::new('pl', 'polski', 'far fa-language') // custom label and icon
  82. //            ])
  83.             ;
  84.     }
  85.     public function configureMenuItems(): iterable
  86.     {
  87.         return [
  88.             MenuItem::linkToDashboard('Home''fa fa-home'),
  89.             MenuItem::section('MUPIs'),
  90.             MenuItem::linkToCrud('Locals''fa fa-building-user'Local::class),
  91.             MenuItem::linkToCrud('Players''fa fa-display'Player::class)
  92.                 ->setPermission('ROLE_ADMIN'),
  93.             MenuItem::section('Admin')->setPermission('ROLE_ADMIN'),
  94.             MenuItem::linkToCrud('Users''fa fa-user'User::class)
  95.                 ->setPermission('ROLE_ADMIN'),
  96.         ];
  97.     }
  98. }