src/Controller/DataController.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\HttpFoundation\JsonResponse;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use App\Repository\RoleRepository;
  8. use App\Repository\JinxRepository;
  9. use App\Model\GameModel;
  10. /**
  11.  * @Route("/{_locale}/data", name="data_")
  12.  */
  13. class DataController extends AbstractController
  14. {
  15.     private $roleRepo;
  16.     private $jinxRepo;
  17.     private $gameModel;
  18.     public function __construct(
  19.         RoleRepository $roleRepo,
  20.         JinxRepository $jinxRepo,
  21.         GameModel $gameModel
  22.     ) {
  23.         $this->roleRepo $roleRepo;
  24.         $this->jinxRepo $jinxRepo;
  25.         $this->gameModel $gameModel;
  26.     }
  27.     /**
  28.      * @Route("/characters", name="characters")
  29.      */
  30.     public function charactersAction(): Response
  31.     {
  32.         return new JsonResponse($this->roleRepo->getFeed());
  33.     }
  34.     /**
  35.      * @Route("/jinx", name="jinx")
  36.      */
  37.     public function jinxAction(): Response
  38.     {
  39.         return new JsonResponse($this->jinxRepo->getFeed());
  40.     }
  41.     /**
  42.      * @Route("/game", name="game")
  43.      */
  44.     public function gameAction(): Response
  45.     {
  46.         return new JsonResponse($this->gameModel->getFeed());
  47.     }
  48. }