src/Controller/LocationController.php line 43

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\ProctorsRepository;
  4. use App\Service\LocationsService;
  5. use App\Util\ParameterUtil;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. class LocationController extends BaseController
  10. {
  11. /**
  12. * @var LocationsService
  13. */
  14. private $locationsService;
  15. public function __construct(LocationsService $locationsService)
  16. {
  17. $this->locationsService = $locationsService;
  18. }
  19. /**
  20. * @Route("/api/getAllLocations")
  21. */
  22. public function getAllLocations(Request $request)
  23. {
  24. return $this->json($this->locationsService->getAllLocationsForAdmin());
  25. }
  26. /**
  27. * @Route("/api/getBranches")
  28. */
  29. public function getBranches(Request $request)
  30. {
  31. return $this->json($this->locationsService->getBranches());
  32. }
  33. /**
  34. * @Route("/api/admin/addEditLocation")
  35. */
  36. public function addEditLocation(Request $request)
  37. {
  38. $content = $this->getContent($request);
  39. $location = $this->locationsService->AddEditLocation(
  40. $content->get('locationId'),
  41. ParameterUtil::getRequired($content->get('branchId')),
  42. ParameterUtil::getRequired($content->get('name')),
  43. $content->get('contact'),
  44. $content->get('seats'),
  45. $content->get('limitTo1Test'),
  46. $content->get('address'),
  47. $content->get('city'),
  48. $content->get('state'),
  49. $content->get('zip'),
  50. $content->get('country'),
  51. $content->get('phone'),
  52. $content->get('gender'),
  53. $content->get('active'),
  54. $content->get('adminOnly'),
  55. $content->get('byAppointment')
  56. );
  57. return $this->json($location);
  58. }
  59. /**
  60. * @Route("/api/getActiveLocations")
  61. */
  62. public function getActiveLocations(Request $request)
  63. {
  64. return $this->json($this->locationsService->getActiveLocations());
  65. }
  66. /**
  67. * @Route("/api/getAllActiveLocations")
  68. */
  69. public function getAllActiveLocations(Request $request)
  70. {
  71. $studentId = parent::getStudentId($request);
  72. $response = $this->locationsService->getAllActiveLocations($studentId);
  73. return new Response(json_encode($response));
  74. }
  75. /**
  76. * @Route("/api/getActiveLocationsAndProctors")
  77. */
  78. public function getActiveLocationsAndProctors(Request $request,ProctorsRepository $proctorsRepository)
  79. {
  80. $studentId = parent::getStudentId($request);
  81. $locations = $this->locationsService->getAllActiveLocations($studentId);
  82. $proctors = $proctorsRepository->findAllProctors();
  83. $response = ['locations' => $locations,'proctors' => $proctors];
  84. return new Response(json_encode($response));
  85. }
  86. /**
  87. * @Route("/api/getAllActiveLocationsAndProctors")
  88. */
  89. public function getAllActiveLocationsAndProctors(Request $request,ProctorsRepository $proctorsRepository)
  90. {
  91. $locations = $this->locationsService->getAllActiveLocationsGeneral();
  92. $proctors = $proctorsRepository->findAllProctors();
  93. $response = ['locations' => $locations,'proctors' => $proctors];
  94. return new Response(json_encode($response));
  95. }
  96. /**
  97. * @Route("/api/getLastActiveLocation")
  98. */
  99. public function getLastActiveLocation(Request $request)
  100. {
  101. $studentId = parent::getStudentId($request);
  102. $response = $this->locationsService->getLastActiveLocation($studentId);
  103. return new Response(json_encode($response));
  104. }
  105. }