Skip to content

Commit

Permalink
Fixed batch action routes with pretty URLs
Browse files Browse the repository at this point in the history
This seems to be some kind of bug in easy-admin-bundle, but it can be fixed/worked around with #[AdminAction] attributes.

See: EasyCorp/EasyAdminBundle#6532
  • Loading branch information
jbtronics committed Dec 1, 2024
1 parent e80a35f commit a4b3fb6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Controller/Admin/PaymentOrderCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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');
Expand Down Expand Up @@ -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');

Expand Down

0 comments on commit a4b3fb6

Please sign in to comment.