<?php
namespace App\Controller;
use App\Repository\ProctorsRepository;
use App\Service\LocationsService;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class LocationController extends BaseController
{
/**
* @var LocationsService
*/
private $locationsService;
public function __construct(LocationsService $locationsService)
{
$this->locationsService = $locationsService;
}
/**
* @Route("/api/getActiveLocations")
*/
public function getActiveLocations(Request $request)
{
return $this->json($this->locationsService->getActiveLocations());
}
/**
* @Route("/api/getAllActiveLocations")
*/
public function getAllActiveLocations(Request $request)
{
$studentId = parent::getStudentId($request);
$response = $this->locationsService->getAllActiveLocations($studentId);
return new Response(json_encode($response));
}
/**
* @Route("/api/getActiveLocationsAndProctors")
*/
public function getActiveLocationsAndProctors(Request $request,ProctorsRepository $proctorsRepository)
{
$studentId = parent::getStudentId($request);
$locations = $this->locationsService->getAllActiveLocations($studentId);
$proctors = $proctorsRepository->findAllProctors();
$response = ['locations' => $locations,'proctors' => $proctors];
return new Response(json_encode($response));
}
/**
* @Route("/api/getAllActiveLocationsAndProctors")
*/
public function getAllActiveLocationsAndProctors(Request $request,ProctorsRepository $proctorsRepository)
{
$locations = $this->locationsService->getAllActiveLocationsGeneral();
$proctors = $proctorsRepository->findAllProctors();
$response = ['locations' => $locations,'proctors' => $proctors];
return new Response(json_encode($response));
}
/**
* @Route("/api/getLastActiveLocation")
*/
public function getLastActiveLocation(Request $request)
{
$studentId = parent::getStudentId($request);
$response = $this->locationsService->getLastActiveLocation($studentId);
return new Response(json_encode($response));
}
}