Private
Public Access
1
0

chg: dev: refactor to use Attributes instead of yaml markdown #4

This commit is contained in:
2026-04-10 12:33:38 +02:00
parent fe2de91e91
commit 15806a6e04
3 changed files with 14 additions and 58 deletions

View File

@@ -16,6 +16,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
/**
* Class MercureController
@@ -39,7 +40,7 @@ class MercureController extends AbstractController
) {
}
/** POST /api/game/start — generate the grid on the server and create the PlayedGame record */
#[Route('/api/game/start', name: 'MineSeekerBundle_api_game_start', methods: ['POST'])]
public function start(Request $request): JsonResponse
{
$data = $request->toArray();
@@ -48,7 +49,7 @@ class MercureController extends AbstractController
return $this->json(['success' => $result]);
}
/** GET /api/game/connect/{gameAssoc} — return grid + current user info (base64 JSON) */
#[Route('/api/game/connect/{gameAssoc}', name: 'MineSeekerBundle_api_game_connect', methods: ['GET'])]
public function connect(string $gameAssoc): Response
{
$payload = $this->rpcManager->getConnectInformation($gameAssoc);
@@ -56,7 +57,7 @@ class MercureController extends AbstractController
return new Response($payload, Response::HTTP_OK, ['Content-Type' => 'text/plain']);
}
/** POST /api/game/join/{gameAssoc} — register the player, broadcast subscription event via Mercure */
#[Route('/api/game/join/{gameAssoc}', name: 'MineSeekerBundle_api_game_join', methods: ['POST'])]
public function join(string $gameAssoc, Request $request): JsonResponse
{
$this->topicManager->subscribe($gameAssoc, $this->resolveUserName($request), $this->getUser());
@@ -64,7 +65,7 @@ class MercureController extends AbstractController
return $this->json(['success' => true]);
}
/** POST /api/game/step/{gameAssoc} — persist the step, broadcast via Mercure, and return revealed cells */
#[Route('/api/game/step/{gameAssoc}', name: 'MineSeekerBundle_api_game_step', methods: ['POST'])]
public function step(string $gameAssoc, Request $request): JsonResponse
{
$result = $this->topicManager->publish($gameAssoc, $this->resolveUserName($request), $request->toArray());
@@ -72,7 +73,7 @@ class MercureController extends AbstractController
return $this->json($result);
}
/** POST /api/game/leave/{gameAssoc} — broadcast disconnect event via Mercure */
#[Route('/api/game/leave/{gameAssoc}', name: 'MineSeekerBundle_api_game_leave', methods: ['POST'])]
public function leave(string $gameAssoc, Request $request): JsonResponse
{
$this->topicManager->unSubscribe($gameAssoc, $this->resolveUserName($request));