src/Controller/LocationController.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\ProctorsRepository;
  4. use App\Service\LocationsService;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. class LocationController extends BaseController
  9. {
  10. /**
  11. * @var LocationsService
  12. */
  13. private $locationsService;
  14. public function __construct(LocationsService $locationsService)
  15. {
  16. $this->locationsService = $locationsService;
  17. }
  18. /**
  19. * @Route("/api/getActiveLocations")
  20. */
  21. public function getActiveLocations(Request $request)
  22. {
  23. return $this->json($this->locationsService->getActiveLocations());
  24. }
  25. /**
  26. * @Route("/api/getAllActiveLocations")
  27. */
  28. public function getAllActiveLocations(Request $request)
  29. {
  30. $studentId = parent::getStudentId($request);
  31. $response = $this->locationsService->getAllActiveLocations($studentId);
  32. return new Response(json_encode($response));
  33. }
  34. /**
  35. * @Route("/api/getActiveLocationsAndProctors")
  36. */
  37. public function getActiveLocationsAndProctors(Request $request,ProctorsRepository $proctorsRepository)
  38. {
  39. $studentId = parent::getStudentId($request);
  40. $locations = $this->locationsService->getAllActiveLocations($studentId);
  41. $proctors = $proctorsRepository->findAllProctors();
  42. $response = ['locations' => $locations,'proctors' => $proctors];
  43. return new Response(json_encode($response));
  44. }
  45. /**
  46. * @Route("/api/getAllActiveLocationsAndProctors")
  47. */
  48. public function getAllActiveLocationsAndProctors(Request $request,ProctorsRepository $proctorsRepository)
  49. {
  50. $locations = $this->locationsService->getAllActiveLocationsGeneral();
  51. $proctors = $proctorsRepository->findAllProctors();
  52. $response = ['locations' => $locations,'proctors' => $proctors];
  53. return new Response(json_encode($response));
  54. }
  55. /**
  56. * @Route("/api/getLastActiveLocation")
  57. */
  58. public function getLastActiveLocation(Request $request)
  59. {
  60. $studentId = parent::getStudentId($request);
  61. $response = $this->locationsService->getLastActiveLocation($studentId);
  62. return new Response(json_encode($response));
  63. }
  64. }