ヤミ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: AgencyAddressController.php
<?php /** * Created by PhpStorm. * User: Ngouaha Ronald * Date: 2018-03-16 * Time: 07:06 */ namespace AppBundle\Controller\Api; use DateTime; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use AppBundle\Form\AddressType; use Symfony\Component\HttpFoundation\JsonResponse; use FOS\RestBundle\Controller\Annotations as Rest; use Symfony\Component\HttpFoundation\Response; use Nelmio\ApiDocBundle\Annotation as Doc; use Symfony\Component\HttpFoundation\Request; use AppBundle\Entity\Company; use AppBundle\Entity\Address; use AppBundle\Entity\Agency; class AgencyAddressController extends Controller { /** * Get the address of an agency ('agencyId' is the Id of the agency) * * @Rest\Get("/agencies/{agencyId}/address") * @Rest\View( * statusCode = 200, * SerializerGroups = {"ADDRESS_DETAILS"} * ) * @Doc\ApiDoc( * section="Agency's address", * resource=true, * description="Get the address of an agency.", * ) */ public function showAction(Agency $agency ) { //TODO return $agency->getAddress(); } /** * Create an address for an agency ('agencyId' is the Id of the agency) * * @Rest\Post("/agencies/{agencyId}/address") * @Rest\View( * statusCode = Response::HTTP_CREATED, * SerializerGroups = {"AGENCY_DETAILS","ADDRESS_DETAILS"} * ) * @ParamConverter("address", converter="fos_rest.request_body") * @Doc\ApiDoc( * section="Agency's address", * resource=true, * description="Create an agency's address.", * input = { * "class"="AppBundle\Form\AddressType", * }, * output = { * "class"="", * } * ) */ public function createAction(Agency $agency, Address $address) { if ($agency->getAddress()) { return new JsonResponse(['error' => 'This agency already has an address. Go to update link'], Response::HTTP_METHOD_NOT_ALLOWED); } $listErrors = $this->get('validator')->validate($address); if (count($listErrors)) { return $this->view($listErrors, Response::HTTP_BAD_REQUEST); } $agency->setAddress($address); $em = $this ->getDoctrine() ->getManager(); $em->flush(); return $agency; } /** * Update the address of an agency ('agencyId' is the Id of the agency) * * @Rest\Put("/agencies/{agencyId}/address") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"AGENCY_DETAILS","ADDRESS_DETAILS"} * ) * @Doc\ApiDoc( * section="Agency's address", * resource=true, * description="Update an agency's address.", * input = { * "class"="AppBundle\Form\AddressType", * }, * output = { * "class"="", * } * ) */ public function updateAction(Request $request, Agency $agency) { if (!$agency->getAddress()) { return new JsonResponse(['eror' => 'This agency does not have an address. Go to create link'], Response::HTTP_METHOD_NOT_ALLOWED); } //processing submitted data $form = $this->createForm(AddressType::class, $agency->getAddress()); $form->submit($request->request->all(), false); $listErrors = $this->get('validator')->validate($agency->getAddress()); if (count($listErrors)) { return $this->view($listErrors, Response::HTTP_BAD_REQUEST); } // No more errors at this point $agency->getAddress()->setLastUpdate(new DateTime()); $em = $this ->getDoctrine() ->getManager(); $em->flush(); return $agency->getAddress(); } }
Coded With 💗 by
0x6ick