src/Controller/Admin/DashboardController.php line 49

  1. <?php
  2. namespace App\Controller\Admin;
  3. use App\Entity\Application;
  4. use App\Entity\ExportExcel;
  5. use App\Entity\FrontTheme;
  6. use App\Entity\Link;
  7. use App\Entity\LinkType;
  8. use App\Entity\LogHistory;
  9. use App\Entity\Notification;
  10. use App\Entity\Role;
  11. use App\Entity\Settings;
  12. use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
  13. use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
  14. use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
  15. use Symfony\Component\HttpFoundation\Response;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. use App\Entity\User;
  18. use App\Flexy\ShopBundle\Entity\Product\Product;
  19. use App\Flexy\ShopBundle\Entity\Store\Store;
  20. use App\Flexy\ShopBundle\Entity\Vendor\Vendor;
  21. use App\Flexy\ShopBundle\Service\FlexyShopStatisticProvider;
  22. use Doctrine\Persistence\ManagerRegistry;
  23. use Symfony\Component\Filesystem\Filesystem;
  24. use Symfony\Component\Finder\Finder;
  25. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  26. use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
  27. use EasyCorp\Bundle\EasyAdminBundle\Orm\EntityRepository;
  28. use Symfony\Component\HttpFoundation\Request;
  29. class DashboardController extends AbstractDashboardController
  30. {
  31.     
  32.     
  33.     public function __construct(
  34.         private readonly ManagerRegistry $doctrine,
  35.         private readonly FlexyShopStatisticProvider $flexyShopStatisticProvider
  36.         )
  37.     {  
  38.         
  39.     }
  40.     
  41.     #[Route(path'/admin'name'admin')]
  42.     public function index(): Response
  43.     {        
  44.         return $this->render("bundles/EasyAdminBundle/welcome.html.twig");
  45.     }
  46.     
  47.     public function configureDashboard(): Dashboard
  48.     {
  49.         $mainSettings $this->doctrine->getManager()->getRepository(Settings::class)->findOneBy(["code"=>"main"]);
  50.         $urlImage "../themes/".strtolower($mainSettings->getAssetFolderName())."/admin/images/logo.png";
  51.         
  52.         return Dashboard::new()
  53.             ->setTitle('<img  style="margin:16px 0 0px 50px" src="'.$urlImage.'" width="90px" />
  54.             <div class="badge badge-primary d-block mt-1">ADMIN</div>
  55.             ')
  56.            // ->setFaviconPath('flexy/img/favicon-flexy-white.png')
  57.            ->renderContentMaximized()
  58.             ->setTranslationDomain('admin')
  59.             ->disableUrlSignatures()
  60.             
  61.             
  62.             ;
  63.             
  64.     }
  65.     public function configureMenuItems(): iterable
  66.     {
  67.                 
  68.         
  69.         
  70.         
  71.        
  72.         
  73.         
  74.         
  75.         /* START : Les Extensions Flexy */ 
  76.         $appications $this->doctrine->getManager()->getRepository(Application::class)->findBy(["isEnabled"=>true],["menuOrder"=>"ASC"]);
  77.         //$finder = new Finder();
  78.         $filesystem = new Filesystem();
  79.         //$finder->directories()->in(__DIR__."/../../Flexy")->depth('== 0');
  80.         
  81.         foreach($appications as $singleApplication){
  82.             
  83.             $bundleExist $filesystem->exists(__DIR__."/../../Flexy/".$singleApplication->getName()."/Flexy".$singleApplication->getName().".php");
  84.             
  85.                if(!$bundleExist){
  86.                     continue;
  87.                }
  88.                
  89.             $bundleName =$singleApplication->getName(); 
  90.             
  91.             if($bundleName == "FrontBundle"){
  92.                 $settings $this->doctrine->getManager()->getRepository(Settings::class)->findOneBy(["code"=>"main"]);
  93.                 
  94.                 $bundleDashboardController 'App\Flexy\FrontBundle\Themes\\'.$settings->getFrontTheme().'\Controller\DashboardController';
  95.             }else{
  96.                 $bundleDashboardController 'App\Flexy\\'.$bundleName.'\Controller\DashboardController';
  97.             }
  98.             
  99.             
  100.             $dashboard = new $bundleDashboardController();
  101.             foreach($dashboard->configureMenuItems() as $menu){
  102.                 yield $menu;
  103.             }
  104.         }
  105.         /* END : Les Extensions Flexy */
  106.         yield MenuItem::section('Parametres')->setPermission("ROLE_ADMIN_DEV");
  107.         
  108.         // yield MenuItem::subMenu('Parametres')->setSubItems([
  109.         //     MenuItem::linkToCrud('Utilisateurs', 'fas fa-shield-alt', User::class);
  110.         // ]);
  111.         yield MenuItem::linkToCrud('Utilisateurs''fas fa-shield-alt'User::class)->setPermission("ROLE_ADMIN_DEV");
  112.         yield MenuItem::linkToCrud('Roles''fas fa-shield-alt'Role::class)->setPermission("ROLE_ADMIN_DEV");
  113.         yield MenuItem::linkToCrud('LinkType''fas fa-gears'LinkType::class)->setPermission("ROLE_ADMIN_DEV");
  114.         yield MenuItem::linkToCrud('Link''fas fa-gears'Link::class)->setPermission("ROLE_ADMIN_DEV");
  115.         yield MenuItem::linkToCrud('Applications''fas fa-shield-alt'Application::class)->setPermission("ROLE_ADMIN_DEV");
  116.         yield MenuItem::linkToCrud('LogHistory''fas fa-shield-alt'LogHistory::class)->setPermission("ROLE_ADMIN_DEV");
  117.         yield MenuItem::linkToCrud('Settings''fas fa-shield-alt'Settings::class)
  118.         ->setAction("edit")
  119.         ->setEntityId(1)
  120.         ->setPermission("ROLE_ADMIN_DEV")
  121.         ;
  122.         yield MenuItem::linkToCrud('Themes''fas fa-shield-alt'FrontTheme::class)->setPermission("ROLE_ADMIN_DEV");
  123.         yield MenuItem::linkToCrud('Export Excel''fas fa-shield-alt'ExportExcel::class)->setController(ExportExcelCrudController::class)->setPermission("ROLE_ADMIN_DEV");
  124.         
  125.     }
  126. }