Custom BatchAction uses old URL with TypeError instead of Pretty URL
Describe the bug
When using Pretty URLs in 4.14.5 and adding a custom BatchAction, the Button gets populated with the old URL style. When calling this URL a TypeError is thrown: EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator::setController(): Argument #1 ($crudControllerFqcn) must be of type string, null given, called in C:\Users\Chris\PhpstormProjects\beratungssoftware\vendor\easycorp\easyadmin-bundle\src\ArgumentResolver\BatchActionDtoResolver.php on line 67
To Reproduce
- Add any Custom BatchAction to a Crud Controller
- Call the BatchAction
Additional context It seems like the custom BatchAction handling just slipped through, when adding the Pretty URLs and only the URL handling needs a small change.
You can fix this error by adding the #[AdminAction] attribute to your batch action method. e.g. something like this (the methods: POST is important here, as batch actions are submitted via POST):
#[AdminAction(routePath: '/sepa-xml-export', routeName: 'admin_payment_order_sepa_xml_export', methods: ['POST'])]
public function sepaXMLExport(BatchActionDto $batchActionDto): Response
{
...
I think it would be fine, if you would need to define a proper admin action path properly (this way it is also explicitly marked that this method is something like a route). But then a proper error message should be shown, and not the current (rather cryptic one).
Thanks a lot @jbtronics for solving my Problem.
@javiereguiluz it would be fantastic to add that to the Documentation
Adding an AdminRoute attribute, as recommended in the doc, worked for me on v4.27.4.