mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-03-17 22:51:04 +01:00
Add Teapot and modify Precondition Error
This commit is contained in:
parent
fe06a2a27a
commit
8f67569b41
@ -6,13 +6,15 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\PreconditionFailedHttpException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
use Exception;
|
||||
use ValueError;
|
||||
|
||||
|
||||
use App\Repository\SiteRepository;
|
||||
use App\Repository\FloorRepository;
|
||||
@ -30,7 +32,11 @@ use App\Entity\Edition;
|
||||
class MapApiController extends AbstractController
|
||||
{
|
||||
//function get_Name($rep) {return $rep->getName();}
|
||||
|
||||
#[Route('/api/teapot')]
|
||||
public function teapot(PlaceNameRepository $pNRep, RoomUserNameRepository $uNRep, PlaceRepository $pRep, SiteRepository $sRep): JsonResponse
|
||||
{
|
||||
throw new HttpException(418);
|
||||
}
|
||||
#[Route('/api/map/test')]
|
||||
public function test(PlaceNameRepository $pNRep, RoomUserNameRepository $uNRep, PlaceRepository $pRep, SiteRepository $sRep): JsonResponse
|
||||
{
|
||||
@ -158,7 +164,7 @@ class MapApiController extends AbstractController
|
||||
else{
|
||||
$names = new ArrayCollection();
|
||||
foreach($places[0]->getNames() as $plName) { $names[] = $plName->getName(); }
|
||||
if ($names->contains($value)) { throw new AccessDeniedHttpException('Warning: \''.$value.'\' is already a name for place '.$placeId);}
|
||||
if ($names->contains($value)) { throw new PreconditionFailedHttpException('Warning: \''.$value.'\' is already a name for place '.$placeId);}
|
||||
else {
|
||||
$pN = new PlaceName();
|
||||
$pN->setPlace($places[0]);
|
||||
@ -187,7 +193,7 @@ class MapApiController extends AbstractController
|
||||
else{
|
||||
$names = new ArrayCollection();
|
||||
foreach($places[0]->getRoomUsers() as $rUser) { $names[] = $rUser->getUserName(); }
|
||||
if ($names->contains($value)) { throw new AccessDeniedHttpException('Warning: \''.$value.'\' is already a name for place '.$placeId);}
|
||||
if ($names->contains($value)) { throw new PreconditionFailedHttpException('Warning: \''.$value.'\' is already a name for place '.$placeId);}
|
||||
else {
|
||||
$rU = new RoomUserName();
|
||||
$rU->setPlace($places[0]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user