Skip to content

Dashboard controllers cannot be extended when pretty URLs are enabled. #6763

@damonjones321

Description

@damonjones321

Describe the bug

Extending a controller from a Dashboard controller when using Pretty Urls causes Crud controllers/routes to appear duplicated when AdminRouteGenerator->generateAdminRoutes is run.

This is not an issue when pretty urls are not enabled.

Error Message:

When using pretty URLs, all CRUD controllers must have unique PHP class names to generate unique route names. However, your application has at least two controllers with the FQCN "%s", generating the route "%s". Even if both CRUD controllers are in different namespaces, they cannot have the same class name. Rename one of these controllers to resolve the issue.

(and yes, I checked for duplicate class names)


To Reproduce

DDev Environment: create a new controller and extend the base DashboardController. Both cache:clear and loading the site will result in an error. Removing config/routes/easyadmin.yaml and re-running cache:clear will allow the site to run as expected.

The issue exists in EasyAdmin v4 since pretty urls and AdminRouteGenerator were added due to the logic in AdminRouteGenerator.


Additional context

Submitted PR #6735, but it probably isn't efficient and definitely doesn't feel clean. It would add an attribute, #[ExtendableDashboard], and some logic in AdminRouteGenerator to skip duplicate dashboard/routes in potentially nested child dashboards while still allowing admin routes to be processed on the extended dashboards if the attribute is set with #[ExtendableDashboard(hasExtraRoutes: true)] on the inherited dashboard controller.

I was able to refactor the affected project, so this is no longer an issue for me (I'll probably close my pull request in a few days). However, I am still submitting this issue because being unable to extend such an integral part of the bundle seems to go against OOP.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions