src/Controller/Admin/DashboardController.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use App\Entity\Notification;
  4. use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
  5. use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
  6. use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use App\Entity\User;
  10. use Symfony\Component\Filesystem\Filesystem;
  11. use Symfony\Component\Finder\Finder;
  12. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  13. use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
  14. use Symfony\UX\Chartjs\Builder\ChartBuilderInterface;
  15. use Symfony\UX\Chartjs\Model\Chart;
  16. class DashboardController extends AbstractDashboardController
  17. {
  18.     /**
  19.      * @Route("/admin", name="admin")
  20.      */
  21.     public function index(): Response
  22.     {
  23.         
  24.   
  25.         if($this->getUser() != null && $this->getUser()->getRoles()[0] == "ROLE_CUSTOMER"){
  26.    
  27.             return $this->redirect("/logout");
  28.         
  29.         }
  30.         else if($this->isGranted('ROLE_ADMIN')) {
  31.    
  32.            
  33.         return $this->render('@Flexy/FrontBundle/templates/dashborad-admin/welcomeadmin.html.twig', [
  34.             'registrationVendorForm' => "dede",
  35.             'registrationCustomerForm' => "dede",
  36.         ]);
  37.        
  38.     }
  39.       return $this->redirect("/login");
  40.     }
  41.     
  42.     public function configureDashboard(): Dashboard
  43.     {
  44.         return Dashboard::new()
  45.             ->setTitle('<img  style="margin:16px 0 20px 14px" src="omall/logo.png" width="150px" />')
  46.            // ->setFaviconPath('flexy/img/favicon-flexy-white.png')
  47.             ->setTranslationDomain('admin')
  48.             
  49.             
  50.             ;
  51.             
  52.     }
  53.     public function configureMenuItems(): iterable
  54.     {
  55.                 
  56.         
  57.         yield MenuItem::linkToDashboard('Tableau de bord''fas fa-home');
  58.         
  59.        
  60.         
  61.         
  62.         /* START : Les Extensions Flexy */ 
  63.         $finder = new Finder();
  64.         $filesystem = new Filesystem();
  65.         $finder->directories()->in(__DIR__."/../../Flexy")->depth('== 0');
  66.         foreach($finder as $directorie){
  67.             
  68.             $bundleExist $filesystem->exists($directorie->getPathname()."/Flexy".$directorie->getFilename().".php");
  69.             
  70.                if(!$bundleExist){
  71.                     continue;
  72.                }
  73.                
  74.             $bundleName =$directorie->getFilename(); 
  75.             
  76.             $bundleDashboardController 'App\Flexy\\'.$bundleName.'\Controller\DashboardController';
  77.             $dashboard = new $bundleDashboardController();
  78.             foreach($dashboard->configureMenuItems() as $menu){
  79.                 yield $menu;
  80.             }
  81.         }
  82.         /* END : Les Extensions Flexy */
  83.         yield MenuItem::section('Parametres');
  84.         
  85.         yield MenuItem::linkToCrud('Utilisateurs''fas fa-shield-alt'User::class);
  86.         
  87.     }
  88. }