chg: dev: refactor to use Attributes instead of yaml markdown #4
This commit is contained in:
@@ -1,53 +0,0 @@
|
|||||||
MineSeekerBundle_homepage:
|
|
||||||
path: /
|
|
||||||
controller: App\Controller\GameController::index
|
|
||||||
|
|
||||||
MineSeekerBundle_gamePlay:
|
|
||||||
path: /play
|
|
||||||
controller: App\Controller\GameController::play
|
|
||||||
|
|
||||||
MineSeekerBundle_gamePlayWId:
|
|
||||||
path: /play/{gameAssoc}
|
|
||||||
controller: App\Controller\GameController::play
|
|
||||||
|
|
||||||
MineSeekerBundle_terms:
|
|
||||||
path: /terms-of-service
|
|
||||||
controller: App\Controller\GameController::terms
|
|
||||||
|
|
||||||
MineSeekerBundle_privacy:
|
|
||||||
path: /privacy-policy
|
|
||||||
controller: App\Controller\GameController::privacy
|
|
||||||
|
|
||||||
MineSeekerBundle_contact:
|
|
||||||
path: /contact
|
|
||||||
controller: App\Controller\GameController::contact
|
|
||||||
|
|
||||||
MineSeekerBundle_landing:
|
|
||||||
path: /landing-page
|
|
||||||
controller: App\Controller\GameController::landing
|
|
||||||
|
|
||||||
MineSeekerBundle_api_game_start:
|
|
||||||
path: /api/game/start
|
|
||||||
controller: App\Controller\MercureController::start
|
|
||||||
methods: [POST]
|
|
||||||
|
|
||||||
MineSeekerBundle_api_game_connect:
|
|
||||||
path: /api/game/connect/{gameAssoc}
|
|
||||||
controller: App\Controller\MercureController::connect
|
|
||||||
methods: [GET]
|
|
||||||
|
|
||||||
MineSeekerBundle_api_game_join:
|
|
||||||
path: /api/game/join/{gameAssoc}
|
|
||||||
controller: App\Controller\MercureController::join
|
|
||||||
methods: [POST]
|
|
||||||
|
|
||||||
MineSeekerBundle_api_game_step:
|
|
||||||
path: /api/game/step/{gameAssoc}
|
|
||||||
controller: App\Controller\MercureController::step
|
|
||||||
methods: [POST]
|
|
||||||
|
|
||||||
MineSeekerBundle_api_game_leave:
|
|
||||||
path: /api/game/leave/{gameAssoc}
|
|
||||||
controller: App\Controller\MercureController::leave
|
|
||||||
methods: [POST]
|
|
||||||
|
|
||||||
@@ -13,6 +13,7 @@ namespace App\Controller;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class GameController
|
* Class GameController
|
||||||
@@ -36,11 +37,14 @@ class GameController extends AbstractController
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/', name: 'MineSeekerBundle_homepage')]
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
return $this->render('Game/index.html.twig');
|
return $this->render('Game/index.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/play', name: 'MineSeekerBundle_gamePlay')]
|
||||||
|
#[Route('/play/{gameAssoc}', name: 'MineSeekerBundle_gamePlayWId')]
|
||||||
public function play(): Response
|
public function play(): Response
|
||||||
{
|
{
|
||||||
return $this->render('Game/play.html.twig', [
|
return $this->render('Game/play.html.twig', [
|
||||||
@@ -50,21 +54,25 @@ class GameController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/privacy-policy', name: 'MineSeekerBundle_privacy')]
|
||||||
public function privacy(): Response
|
public function privacy(): Response
|
||||||
{
|
{
|
||||||
return $this->render('Official/privacy.html.twig');
|
return $this->render('Official/privacy.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/terms-of-service', name: 'MineSeekerBundle_terms')]
|
||||||
public function terms(): Response
|
public function terms(): Response
|
||||||
{
|
{
|
||||||
return $this->render('Official/terms.html.twig');
|
return $this->render('Official/terms.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/contact', name: 'MineSeekerBundle_contact')]
|
||||||
public function contact(): Response
|
public function contact(): Response
|
||||||
{
|
{
|
||||||
return $this->render('Official/contact.html.twig');
|
return $this->render('Official/contact.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/landing-page', name: 'MineSeekerBundle_landing')]
|
||||||
public function landing(): Response
|
public function landing(): Response
|
||||||
{
|
{
|
||||||
return $this->render('Official/landing.html.twig');
|
return $this->render('Official/landing.html.twig');
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class MercureController
|
* 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
|
public function start(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$data = $request->toArray();
|
$data = $request->toArray();
|
||||||
@@ -48,7 +49,7 @@ class MercureController extends AbstractController
|
|||||||
return $this->json(['success' => $result]);
|
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
|
public function connect(string $gameAssoc): Response
|
||||||
{
|
{
|
||||||
$payload = $this->rpcManager->getConnectInformation($gameAssoc);
|
$payload = $this->rpcManager->getConnectInformation($gameAssoc);
|
||||||
@@ -56,7 +57,7 @@ class MercureController extends AbstractController
|
|||||||
return new Response($payload, Response::HTTP_OK, ['Content-Type' => 'text/plain']);
|
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
|
public function join(string $gameAssoc, Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->topicManager->subscribe($gameAssoc, $this->resolveUserName($request), $this->getUser());
|
$this->topicManager->subscribe($gameAssoc, $this->resolveUserName($request), $this->getUser());
|
||||||
@@ -64,7 +65,7 @@ class MercureController extends AbstractController
|
|||||||
return $this->json(['success' => true]);
|
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
|
public function step(string $gameAssoc, Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$result = $this->topicManager->publish($gameAssoc, $this->resolveUserName($request), $request->toArray());
|
$result = $this->topicManager->publish($gameAssoc, $this->resolveUserName($request), $request->toArray());
|
||||||
@@ -72,7 +73,7 @@ class MercureController extends AbstractController
|
|||||||
return $this->json($result);
|
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
|
public function leave(string $gameAssoc, Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->topicManager->unSubscribe($gameAssoc, $this->resolveUserName($request));
|
$this->topicManager->unSubscribe($gameAssoc, $this->resolveUserName($request));
|
||||||
|
|||||||
Reference in New Issue
Block a user