EasyCorp / EasyAdminBundle

EasyAdmin is a fast, beautiful and modern admin generator for Symfony applications.
MIT License
4.06k stars 1.02k forks source link

The name of the route associated to "App\Controller\ExportController::index" cannot be determined #5864

Open bargoud opened 1 year ago

bargoud commented 1 year ago

Describe the bug Since updated to version 4.7.1, my Controller cause this error :

The name of the route associated to "App\Controller\ExportController::index" cannot be determined. Clear the application cache to run the EasyAdmin cache warmer, which generates the needed data to find this route." at /var/www/vhosts/crf31.fr/atlas/vendor/easycorp/easyadmin-bundle/src/Factory/AdminContextFactory.php line 92

Problem already reported on https://github.com/EasyCorp/EasyAdminBundle/commit/8e350822daa35ff4761e20e02cd0f126bf9b3ae5

To Reproduce Simply update to v4.7.1. Downgrade to 4.7.0 fix the issue.

Additional context My ExportController extends my AdminController which extends AbstractDashboardController

chapterjason commented 1 year ago

Had the same issue. In my case it was a #[Route] in my DashboardController, as a workaround I extracted the route and made the functionality accessible over a crud action.

Atko commented 1 year ago

Same issue here when I try to access my custom actions in my dashboard controller with their own route:

The name of the route associated to "App\Controller\Admin\DashboardController::index" cannot be determined. Clear the application cache to run the EasyAdmin cache warmer, which generates the needed data to find this route.

My DashboardController looks like this:

<?php

namespace App\Controller\Admin;

use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class DashboardController extends AbstractDashboardController
{
    public function __construct()
    {
        (...)
    }

    public function configureAssets(): Assets
    {
        (...)
    }

    /**
     * @Route("/", name="admin")
     */
    public function index(): Response
    {
        return $this->render('admin/dashboard.html.twig');
    }

    public function configureDashboard(): Dashboard
    {
        (...)
    }

    public function configureMenuItems(): iterable
    {
        yield MenuItem::linktoDashboard('Dashboard', 'fa fa-home');
        yield MenuItem::linkToRoute('Booking overview', 'fa-solid fa-book-open', 'booking_dashboard');
        yield MenuItem::linkToRoute('Cleaning overview', 'fa-solid fa-broom', 'cleaning_dashboard');
        yield MenuItem::linkToRoute('Meters overview', 'fa-solid fa-broom', 'meters_dashboard');
    }

    /**
     * @Route("/cleaning", name="cleaning_dashboard")
     */
    public function cleaningIndex(Request $request): Response
    {
        return $this->render('admin/cleaner-dashboard.html.twig', []);
    }

    /**
     * @Route("/booking", name="booking_dashboard")
     */
    public function bookingIndex(): Response
    {
        return $this->render('admin/booking-dashboard.html.twig', []);
    }

    /**
     * @Route("/meters", name="meters_dashboard")
     */
    public function metersIndex(): Response
    {
        return $this->render('admin/meters-dashboard.html.twig', []);
    }
}

Technically the changes made in this commit made this error: https://github.com/EasyCorp/EasyAdminBundle/commit/8e350822daa35ff4761e20e02cd0f126bf9b3ae5

Rolling back this only commit makes everything run as intended...

Atko commented 1 year ago

One more thing: I can access my custom actions in my DashboardController by their route name or by their own custom url:

/admin/cleaning or /admin/?routeName=cleaning_dashboard

In the first case the $currentRouteName variable's value is 'cleaning_dashboard' in the second case its just simply 'admin'.

javiereguiluz commented 1 year ago

This has been fixed in the new 4.7.2 release: https://github.com/EasyCorp/EasyAdminBundle/releases/tag/v4.7.2

Hopefully we can create a minimal reproducer for this bug so we can fix the original bug without introducing the new bug reported here. Thanks.

aless673 commented 8 months ago

If lazy is turned on for your controllers in your services.yaml it will show this error

The name of the route associated to "Container3CNDF2j\DashboardControllerGhostB927767::index" cannot be determined. Clear the application cache to run the EasyAdmin cache warmer, which generates the needed data to find this route.

versions