Describe the bug
If I use the URL Builder in the user dashboard class then. It generates a bogus url.
False: http://localhost/user?crudAction=edit&crudId=20........................
Right: http://localhost/admin?crudAction=edit&crudId=20........................
To Reproduce
UserDashboardController.php
/**
* Build the User-Profil Edit Url for the admin to use the url var in a email
* @param $id
* @return CrudUrlBuilder
*/
protected function createEditUrl($id): string
{
return $this->crudUrlGenerator->build()
->setDashboard(AdminDashboardController::class)
->setController(AdminUserCrudController::class)
->setAction(Action::EDIT)
->setEntityId($id);
}
(OPTIONAL) Additional context
Symfony 5.1
EA dev-master 6309496
I only have one application with multiple Dashboards and I use this feature to generate links and it works as expected 馃
First, check the contents of the var/cache/<env>/easyadmin/routes-dashboard.php file and see if the routes are correctly detected there.
If that's correct, add some dump() or dd() calls (or use Xdebug if you prefer) in the CrudUrlBuilder class to see when the route is wrongly generated (maybe there's a bug when getting the route? maybe there's some error with query string params which is messing everything?) Thanks!
Tomorrow i show, today i found nothing more
routes ok in cache
<?php return array (
'admin' => 'App\\Controller\\Admin\\AdminDashboardController::index',
'user' => 'App\\Controller\\Admin\\UserDashboardController::index',
'admin_user_profil' => 'App\\Controller\\Admin\\UserProfilDashboardController::index',
);
xdebug show nothing all looks good
https://github.com/EasyCorp/EasyAdminBundle/blob/719f1c9948e2f9e30d1f7ddf33047b4ff56d141f/src/Router/CrudUrlBuilder.php#L159-L172
Here is the problem
I call the crudUrlGenerator->build() inside of UserDashboardController.php
so
dont set
solution
if (null === $this->dashboardRoute or !empty($this->routeParameters['dashboardControllerFqcn']))
or better idea???
@rogergerecke I think I finally found the real issue. Thanks for providing the examples and for trying to fix this yourself! See #3599 and please check if it fixes the problem for you. Thanks!
@javiereguiluz fixit not.
Yes its create a working linkhttp://localhost/user?crudAction=edit&crudId=20def93&dashboardControllerFqcn=
But the /user part is false so a normal user can have access to admin function.
Corect url must by /admin contain i think.
To Reproduce
Create tow Dashborads
UserDashboardController.php with @Route("/user", name="user")AdminDashboardController.php with @Route("/admin", name="admin")In the UserDashboardController.php I build the URL and
->setDashboard(AdminDashboardController::class)
to submit it in a mail to the admin letter
Is this a mistake or I do not understand how the crudUrlGenerator->build should be used ????
@rogergerecke I'm going to merge the related PR because even if it doesn't fix your bug, it fixes a bug in the generation of URLs. I will keep this issue open, but I still can't see why this happens after applying this fix.
dev-master 3063c1d works correct generate the right url
Most helpful comment
dev-master 3063c1d works correct generate the right url