Skip to content

Commit

Permalink
Merge pull request #10 from Prokyonn/enhancement/symfony-routes
Browse files Browse the repository at this point in the history
Add dynamic route generation for the js api implementation
  • Loading branch information
veewee authored Mar 1, 2024
2 parents 1dfc2b0 + c7e873b commit 458883b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion assets/admin/api/fetchMessage.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion assets/admin/api/retryMessage.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
})
);
Expand Down
2 changes: 1 addition & 1 deletion src/Presentation/Controller/Admin/DeleteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/Presentation/Controller/Admin/RequeueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', options: ['expose' => true], methods: ['PUT'])]
final class RequeueController extends AbstractSecuredMessengerFailedQueueController implements SecuredControllerInterface
{
public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion src/Presentation/Controller/Admin/RetryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 458883b

Please sign in to comment.