ヤミ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: CompanyAgencyController.php
<?php namespace AppBundle\Controller\Api; use FOS\RestBundle\Controller\FOSRestController; use FOS\RestBundle\Controller\Annotations as Rest; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Doctrine\ORM\Mapping as ORM; use Nelmio\ApiDocBundle\Annotation as Doc; use AppBundle\Entity\Agency; use AppBundle\Entity\Company; use AppBundle\Entity\Address; use AppBundle\Form\AgencyType; use AppBundle\Form\AddressType; class CompanyAgencyController extends FOSRestController { /** * Get the list of all agencies. * @param integer $companyId * * @Rest\Get("/companies/{companyId}/agencies") * @Rest\View( * SerializerGroups = {"LIST"} * ) * * @Doc\ApiDoc( * section="Agencies", * resource=true, * description="Get the list of all agencies.", * ) */ public function listAction(Company $company) { //TODO $agencies = $this ->getDoctrine() ->getRepository('AppBundle:Agency') ->findByCompany($company); return $agencies; } /** * Get one agency that belongs to the company which id is 'companyId * @param integer $companyId * * @Rest\Get("/companies/{companyId}/agencies/{agencyId}") * @Rest\View( * SerializerGroups = {"AGENCY_DETAILS","ADDRESS_DETAILS"} * ) * @Doc\ApiDoc( * section="Agencies", * resource=true, * description="Get one agency that belongs to the company which id is 'companyId.", * ) */ public function showAction(Agency $agency) { //TODO return $agency; } /** * Creates a new agency that belongs to the given company * * @param integer $companyId * * @Rest\Post("/companies/{companyId}/agencies") * @Rest\View( * statusCode = Response::HTTP_CREATED, * SerializerGroups = {"AGENCY_DETAILS","ADDRESS_DETAILS"} * ) * @Doc\ApiDoc( * section="Agencies", * resource=true, * description="Creates a new agency that belongs to the company which id is 'companyId'.", * input = { * "class"="AppBundle\Form\AgencyType", * }, * output = { * "class"="", * } * ) */ public function createAction( Request $request, Company $company) { $agency = new Agency(); $form = $this->createForm(AgencyType::class, $agency); $form->submit($request->request->all(), false); $listErrors = $this->get('validator')->validate($agency); if (count($listErrors)) { return $this->view($listErrors, Response::HTTP_BAD_REQUEST); } /* * the bloc directly sets an address for the agency if a key "address" is specified in the request body * if the key in not found the new fresh address will remain empty. */ $address = new Address(); $form = $this->createForm(AddressType::class, $address); $form->submit($request->get("address"), false); $listErrors = $this->get('validator')->validate($address); if (count($listErrors)) { return $this->view($listErrors, Response::HTTP_BAD_REQUEST); } /* * No errors after this point */ $agency->setAddress($address); $agency->setCompany($company); $em = $this ->getDoctrine() ->getManager(); $em->persist($agency); $em->flush(); return $agency; } /** * Update an agency that belongs to the company which id is 'companyId * @param integer $companyId * * @Rest\Put("/companies/{companyId}/agencies/{agencyId}") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"AGENCY_DETAILS","ADDRESS_DETAILS"} *) * @Doc\ApiDoc( * section="Agencies", * resource=true, * description="update an agency that belongs to the company which id is 'companyId'.", * input = { * "class"="AppBundle\Form\AgencyType", * }, * output = { * "class"="", * } * ) */ public function updateAction( Request $request, Agency $agency) { /* * here we don't create a new fresh agency but we get an existing one from doctrine * remember the donctrine parm converter. */ $form = $this->createForm(AgencyType::class, $agency); $form->submit($request->request->all(), false); $listErrors = $this->get('validator')->validate($agency); if (count($listErrors)) { return $this->view($listErrors, Response::HTTP_BAD_REQUEST); } /** * edit the assigned address too */ $address = $agency->getAddress(); $form = $this->createForm(AddressType::class, $address ); $form->submit($request->get("address"), false); $listErrors = $this->get('validator')->validate($address); if (count($listErrors)) { return $this->view($listErrors, Response::HTTP_BAD_REQUEST); } $em = $this ->getDoctrine() ->getManager(); $em->persist($agency); $em->flush(); return $agency; } /** * Deactivates an agency that belongs to the company which id is 'companyId * @param integer $companyId * * @Rest\Delete("/companies/{companyId}/agencies/{agencyId}") * @Rest\View( * statusCode = Response::HTTP_OK *) * @Doc\ApiDoc( * section="Agencies", * resource=true, * description="Deactivates an agency that belongs to the company which id is 'companyId'.", * ) */ public function deleteAction(Agency $agency) { $agency->setActive(false); // No more errors at this point $em = $this ->getDoctrine() ->getManager(); $em->flush(); // return new JsonResponse('', Response::HTTP_NO_CONTENT); return $agency; } }
Coded With 💗 by
0x6ick