<?php

namespace App\Controller\Admin;

use App\Entity\CarteFractal;
use App\Entity\ClasseurFractal;
use App\Entity\MembreFractal;
use App\Entity\CollectionFractal;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class DashboardController extends AbstractDashboardController
{
    #[Route('/admin', name: 'admin')]
    public function index(): Response
    {
        $routeBuilder = $this->container->get(AdminUrlGenerator::class);
        $url = $routeBuilder->setController(ClasseurFractalCrudController::class)->generateUrl();
        return $this->redirect($url);
    }

    public function configureDashboard(): Dashboard
    {
        return Dashboard::new()
            ->setTitle('CollectionFractal Admin');
    }

    public function configureMenuItems(): iterable
    {
        yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home');
        yield MenuItem::linkToCrud('Classeurs Fractal','fas fa-list', ClasseurFractal::class);
        yield MenuItem::linkToCrud('Cartes Fractal', 'fas fa-list', CarteFractal::class);
        yield MenuItem::linkToCrud('Membres Fractal', 'fas fa-list', MembreFractal::class);
        yield MenuItem::linkToCrud('Collections Fractal', 'fas fa-list', CollectionFractal::class);
    }
}
