src/Controller/Admin/DashboardController.php line 49
<?php
namespace App\Controller\Admin;
use App\Entity\Application;
use App\Entity\ExportExcel;
use App\Entity\FrontTheme;
use App\Entity\Link;
use App\Entity\LinkType;
use App\Entity\LogHistory;
use App\Entity\Notification;
use App\Entity\Role;
use App\Entity\Settings;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Entity\User;
use App\Flexy\ShopBundle\Entity\Product\Product;
use App\Flexy\ShopBundle\Entity\Store\Store;
use App\Flexy\ShopBundle\Entity\Vendor\Vendor;
use App\Flexy\ShopBundle\Service\FlexyShopStatisticProvider;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
use EasyCorp\Bundle\EasyAdminBundle\Orm\EntityRepository;
use Symfony\Component\HttpFoundation\Request;
class DashboardController extends AbstractDashboardController
{
public function __construct(
private readonly ManagerRegistry $doctrine,
private readonly FlexyShopStatisticProvider $flexyShopStatisticProvider
)
{
}
#[Route(path: '/admin', name: 'admin')]
public function index(): Response
{
return $this->render("bundles/EasyAdminBundle/welcome.html.twig");
}
public function configureDashboard(): Dashboard
{
$mainSettings = $this->doctrine->getManager()->getRepository(Settings::class)->findOneBy(["code"=>"main"]);
$urlImage = "../themes/".strtolower($mainSettings->getAssetFolderName())."/admin/images/logo.png";
return Dashboard::new()
->setTitle('<img style="margin:16px 0 0px 50px" src="'.$urlImage.'" width="90px" />
<div class="badge badge-primary d-block mt-1">ADMIN</div>
')
// ->setFaviconPath('flexy/img/favicon-flexy-white.png')
->renderContentMaximized()
->setTranslationDomain('admin')
->disableUrlSignatures()
;
}
public function configureMenuItems(): iterable
{
/* START : Les Extensions Flexy */
$appications = $this->doctrine->getManager()->getRepository(Application::class)->findBy(["isEnabled"=>true],["menuOrder"=>"ASC"]);
//$finder = new Finder();
$filesystem = new Filesystem();
//$finder->directories()->in(__DIR__."/../../Flexy")->depth('== 0');
foreach($appications as $singleApplication){
$bundleExist = $filesystem->exists(__DIR__."/../../Flexy/".$singleApplication->getName()."/Flexy".$singleApplication->getName().".php");
if(!$bundleExist){
continue;
}
$bundleName =$singleApplication->getName();
if($bundleName == "FrontBundle"){
$settings = $this->doctrine->getManager()->getRepository(Settings::class)->findOneBy(["code"=>"main"]);
$bundleDashboardController = 'App\Flexy\FrontBundle\Themes\\'.$settings->getFrontTheme().'\Controller\DashboardController';
}else{
$bundleDashboardController = 'App\Flexy\\'.$bundleName.'\Controller\DashboardController';
}
$dashboard = new $bundleDashboardController();
foreach($dashboard->configureMenuItems() as $menu){
yield $menu;
}
}
/* END : Les Extensions Flexy */
yield MenuItem::section('Parametres')->setPermission("ROLE_ADMIN_DEV");
// yield MenuItem::subMenu('Parametres')->setSubItems([
// MenuItem::linkToCrud('Utilisateurs', 'fas fa-shield-alt', User::class);
// ]);
yield MenuItem::linkToCrud('Utilisateurs', 'fas fa-shield-alt', User::class)->setPermission("ROLE_ADMIN_DEV");
yield MenuItem::linkToCrud('Roles', 'fas fa-shield-alt', Role::class)->setPermission("ROLE_ADMIN_DEV");
yield MenuItem::linkToCrud('LinkType', 'fas fa-gears', LinkType::class)->setPermission("ROLE_ADMIN_DEV");
yield MenuItem::linkToCrud('Link', 'fas fa-gears', Link::class)->setPermission("ROLE_ADMIN_DEV");
yield MenuItem::linkToCrud('Applications', 'fas fa-shield-alt', Application::class)->setPermission("ROLE_ADMIN_DEV");
yield MenuItem::linkToCrud('LogHistory', 'fas fa-shield-alt', LogHistory::class)->setPermission("ROLE_ADMIN_DEV");
yield MenuItem::linkToCrud('Settings', 'fas fa-shield-alt', Settings::class)
->setAction("edit")
->setEntityId(1)
->setPermission("ROLE_ADMIN_DEV")
;
yield MenuItem::linkToCrud('Themes', 'fas fa-shield-alt', FrontTheme::class)->setPermission("ROLE_ADMIN_DEV");
yield MenuItem::linkToCrud('Export Excel', 'fas fa-shield-alt', ExportExcel::class)->setController(ExportExcelCrudController::class)->setPermission("ROLE_ADMIN_DEV");
}
}