From a4b3fb6e8a5f5a51ba94239da272e94333d4c9bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 1 Dec 2024 02:31:59 +0100 Subject: [PATCH] Fixed batch action routes with pretty URLs This seems to be some kind of bug in easy-admin-bundle, but it can be fixed/worked around with #[AdminAction] attributes. See: https://github.com/EasyCorp/EasyAdminBundle/issues/6532 --- src/Controller/Admin/PaymentOrderCrudController.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Controller/Admin/PaymentOrderCrudController.php b/src/Controller/Admin/PaymentOrderCrudController.php index fc29dbb..2c455d0 100644 --- a/src/Controller/Admin/PaymentOrderCrudController.php +++ b/src/Controller/Admin/PaymentOrderCrudController.php @@ -35,6 +35,7 @@ use App\Services\EmailConfirmation\ConfirmationEmailSender; use App\Services\PaymentOrderMailLinkGenerator; use Doctrine\ORM\EntityManagerInterface; +use EasyCorp\Bundle\EasyAdminBundle\Attribute\AdminAction; use EasyCorp\Bundle\EasyAdminBundle\Attribute\AdminCrud; use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; @@ -85,6 +86,7 @@ public static function getEntityFqcn(): string return PaymentOrder::class; } + #[AdminAction(routePath: '/action-sepa-xml-export', routeName: 'admin_action_payment_order_sepa_xml_export', methods: ['POST'])] public function sepaXMLExport(BatchActionDto $batchActionDto): Response { return $this->redirect( @@ -94,6 +96,7 @@ public function sepaXMLExport(BatchActionDto $batchActionDto): Response ); } + #[AdminAction(routePath: '/action-references-export', routeName: 'admin_action_payment_order_references_export', methods: ['POST'])] public function referencesExport(BatchActionDto $batchActionDto): Response { $this->denyAccessUnlessGranted('ROLE_SHOW_PAYMENT_ORDERS'); @@ -283,10 +286,6 @@ public function configureActions(Actions $actions): Actions ->linkToRoute('payment_order_pdf_stura', fn(PaymentOrder $paymentOrder): array => [ 'id' => $paymentOrder->getId(), ]) - //Together with some backend.js logic, this attribute will prevent the modal from showing - ->setHtmlAttributes([ - 'data-action-batch-no-confirm' => 'true', - ]) ->displayIf(fn(PaymentOrder $paymentOrder): bool => $paymentOrder->isFactuallyCorrectChecked() && $paymentOrder->isMathematicallyCorrectChecked()) ->setCssClass('btn btn-success');