From 6431ebcbc4a0efb7f5c9235e43d9aa9134cb388e Mon Sep 17 00:00:00 2001 From: Prokyonn Date: Fri, 1 Mar 2024 00:47:09 +0100 Subject: [PATCH 1/3] Add dynamic route generation --- assets/admin/api/fetchMessage.js | 3 ++- assets/admin/api/retryMessage.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/admin/api/fetchMessage.js b/assets/admin/api/fetchMessage.js index e29a386..3f54873 100644 --- a/assets/admin/api/fetchMessage.js +++ b/assets/admin/api/fetchMessage.js @@ -1,6 +1,7 @@ import {Requester} from "sulu-admin-bundle/services"; import {runActionOnServer} from "../utilities/run-action-on-server"; import {tryParseFailedMessage} from "../types/failed-message"; +import symfonyRouting from "fos-jsrouting/router"; /** * @param {number} messageId @@ -10,7 +11,7 @@ export async function fetchMessage( messageId, ) { const response = await runActionOnServer( - Requester.get(`/admin/api/messenger-failed-queue/${messageId}`) + Requester.get(symfonyRouting.generate('tailr.messenger_failed_queue_fetch', {id: messageId})) ); return tryParseFailedMessage(response); diff --git a/assets/admin/api/retryMessage.js b/assets/admin/api/retryMessage.js index f9543a9..f92273f 100644 --- a/assets/admin/api/retryMessage.js +++ b/assets/admin/api/retryMessage.js @@ -1,5 +1,6 @@ import {Requester} from "sulu-admin-bundle/services"; import {runActionOnServer} from "../utilities/run-action-on-server"; +import symfonyRouting from "fos-jsrouting/router"; /** * @param {number[]} messageIdentifiers @@ -11,7 +12,7 @@ export async function retryMessage( withRequeue, ) { await runActionOnServer( - Requester.put(`/admin/api/messenger-failed-queue/${withRequeue ? 'requeue' : 'retry'}`, { + Requester.put(symfonyRouting.generate(`tailr.messenger_failed_queue_${withRequeue ? 'requeue' : 'retry'}`), { identifiers: messageIdentifiers }) ); From 66fa990d8d18b56da4aa671758faa7e2c8f561de Mon Sep 17 00:00:00 2001 From: Toon Verwerft Date: Fri, 1 Mar 2024 09:33:12 +0100 Subject: [PATCH 2/3] Fix naming of routes --- src/Presentation/Controller/Admin/DeleteController.php | 2 +- src/Presentation/Controller/Admin/RequeueController.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Presentation/Controller/Admin/DeleteController.php b/src/Presentation/Controller/Admin/DeleteController.php index e917fc1..36cdb54 100644 --- a/src/Presentation/Controller/Admin/DeleteController.php +++ b/src/Presentation/Controller/Admin/DeleteController.php @@ -10,7 +10,7 @@ use Symfony\Component\Routing\Annotation\Route; use Tailr\SuluMessengerFailedQueueBundle\Domain\Command\DeleteHandlerInterface; -#[Route(path: '/messenger-failed-queue/{id}', name: 'app.messenger_failed_queue_delete', methods: ['DELETE'])] +#[Route(path: '/messenger-failed-queue/{id}', name: 'tailr.messenger_failed_queue_delete', methods: ['DELETE'])] final class DeleteController extends AbstractSecuredMessengerFailedQueueController implements SecuredControllerInterface { public function __construct( diff --git a/src/Presentation/Controller/Admin/RequeueController.php b/src/Presentation/Controller/Admin/RequeueController.php index 0d4dd96..3456f90 100644 --- a/src/Presentation/Controller/Admin/RequeueController.php +++ b/src/Presentation/Controller/Admin/RequeueController.php @@ -16,7 +16,7 @@ use function Psl\Type\shape; use function Psl\Type\vec; -#[Route(path: '/messenger-failed-queue/requeue', name: 'app.messenger_failed_queue_requeue', methods: ['PUT'])] +#[Route(path: '/messenger-failed-queue/requeue', name: 'tailr.messenger_failed_queue_requeue', methods: ['PUT'])] final class RequeueController extends AbstractSecuredMessengerFailedQueueController implements SecuredControllerInterface { public function __construct( From c7e873beb16bea2e08ecd00513b85b514672a0d6 Mon Sep 17 00:00:00 2001 From: Prokyonn Date: Fri, 1 Mar 2024 10:25:19 +0100 Subject: [PATCH 3/3] Expose controller routes --- src/Presentation/Controller/Admin/RequeueController.php | 2 +- src/Presentation/Controller/Admin/RetryController.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Presentation/Controller/Admin/RequeueController.php b/src/Presentation/Controller/Admin/RequeueController.php index 3456f90..4589076 100644 --- a/src/Presentation/Controller/Admin/RequeueController.php +++ b/src/Presentation/Controller/Admin/RequeueController.php @@ -16,7 +16,7 @@ use function Psl\Type\shape; use function Psl\Type\vec; -#[Route(path: '/messenger-failed-queue/requeue', name: 'tailr.messenger_failed_queue_requeue', methods: ['PUT'])] +#[Route(path: '/messenger-failed-queue/requeue', name: 'tailr.messenger_failed_queue_requeue', options: ['expose' => true], methods: ['PUT'])] final class RequeueController extends AbstractSecuredMessengerFailedQueueController implements SecuredControllerInterface { public function __construct( diff --git a/src/Presentation/Controller/Admin/RetryController.php b/src/Presentation/Controller/Admin/RetryController.php index 04e8fd7..4cc0e4f 100644 --- a/src/Presentation/Controller/Admin/RetryController.php +++ b/src/Presentation/Controller/Admin/RetryController.php @@ -16,7 +16,7 @@ use function Psl\Type\shape; use function Psl\Type\vec; -#[Route(path: '/messenger-failed-queue/retry', name: 'tailr.messenger_failed_queue_retry', methods: ['PUT'])] +#[Route(path: '/messenger-failed-queue/retry', name: 'tailr.messenger_failed_queue_retry', options: ['expose' => true], methods: ['PUT'])] final class RetryController extends AbstractSecuredMessengerFailedQueueController implements SecuredControllerInterface { public function __construct(