ヤミ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: CompanyController.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\Validator\ConstraintViolationList; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Nelmio\ApiDocBundle\Annotation as Doc; use AppBundle\Entity\Company; use AppBundle\Entity\Address; use AppBundle\Form\CompanyType; use AppBundle\Form\AddressType; class CompanyController extends FOSRestController { /** * Get the list of all companies * * @Rest\Get("/companies") * @Rest\View( * statusCode = Response::HTTP_OK, * SerializerGroups = {"LIST"} * ) * @Doc\ApiDoc( * section="Companies", * resource=true, * description="Get the list of all companies.", * ) */ public function listAction() { //TODO $companies = $this ->getDoctrine() ->getRepository('AppBundle:Company') ->findAll(); return $companies; } /** * The company unique identifier * * @Rest\Get("/companies/{companyId}") * @Rest\View( * statusCode= Response::HTTP_OK, * SerializerGroups = {"LIST", "COMPANY_DETAILS"} *) * @Doc\ApiDoc( * section="Companies", * resource=true, * description="Get one company.", * requirements={ * { * "name"="companyId", * "dataType"="integer", * "requirements"="\d+", * "description"="The company unique identifier." * } * }, * statusCodes={ * Response::HTTP_OK="Returned when successful", * } * ) * */ public function showAction(Company $company) { // TODO return $company; } /** * Create a new company * * @Rest\Post("/companies") * @Rest\View( * statusCode = Response::HTTP_CREATED, * SerializerGroups = {"LIST", "COMPANY_DETAILS"} *) * @Doc\ApiDoc( * section="Companies", * resource=true, * description="Create a new company.", * input = { * "class"="AppBundle\Form\CompanyType", * }, * output = { * "class"="", * }, * statusCodes={ * Response::HTTP_CREATED="Returned when the new company is created", * 400="Returned when a violation is raised by validation" * } * ) */ public function createAction(Request $request) { $company = new Company(); $form = $this->createForm(CompanyType::class, $company); $form->submit($request->request->all(), false); $listErrors = $this->get('validator')->validate($company); if (count($listErrors)) { return $this->view($listErrors, Response::HTTP_BAD_REQUEST); } /* * the bloc 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. */ if ($request->request->has("head_office_address")) { $address = new Address(); $form = $this->createForm(AddressType::class, $address); $form->submit($request->get("head_office_address"), false); $listErrors = $this->get('validator')->validate($address); if (count($listErrors)) { return $this->view($listErrors, Response::HTTP_BAD_REQUEST); } $company->setHeadOfficeAddress($address); } /** * No errors at this point */ $em = $this ->getDoctrine() ->getManager(); $em->persist($company); $em->flush(); return $company; } /** * Update an existing company * * @Rest\Put("/companies/{companyId}") * @Rest\View( * statusCode = Response::HTTP_ACCEPTED, * SerializerGroups = {"LIST", "COMPANY_DETAILS"} *) * @Doc\ApiDoc( * section="Companies", * resource=true, * description="Update one company.", * input = { * "class"="AppBundle\Form\CompanyType", * }, * output = { * "class"="", * }, * statusCodes={ * Response::HTTP_ACCEPTED="Returned when the company update is successful", * 400="Returned when a violation is raised by validation" * } * ) */ public function updateAction(Request $request, Company $company) { //processing submitted data $form = $this->createForm(CompanyType::class, $company); $form->submit($request->request->all(), false); // false correspond a la valeur du parametre 'clearMissing' qui empèche au formulaire de mettre la valeur null aux champs ne figurant pas dans le corps de la requête $listErrors = $this->get('validator')->validate($company); if (count($listErrors)) { return $this->view($listErrors, Response::HTTP_BAD_REQUEST); } // No more errors at this point $em = $this ->getDoctrine() ->getManager(); $em->flush(); return $company; } /** * Deactivate an existing company * * @Rest\Delete("/companies/{companyId}") * @Rest\View( * statusCode = Response::HTTP_OK * ) * @Doc\ApiDoc( * section="Companies", * resource=true, * description="Delete( Deactivates) one company.", * requirements={ * { * "name"="companyId", * "dataType"="integer", * "requirements"="\d+", * "description"="The company unique identifier." * } * }, * statusCodes={ * Response::HTTP_OK="Returned when delete successful", * } * ) * */ public function deleteAction(Company $company) { /** * We don't delete a company. We juste set th active state to 'false' */ $company->setActive(false); $em = $this ->getDoctrine() ->getManager(); $em->flush(); return new JsonResponse('', Response::HTTP_NO_CONTENT); } }
Coded With 💗 by
0x6ick