Example #1
0
 /**
  * @param JobPicture $picture
  * @return JsonResponse
  *
  * @Route("/cto/ajax/removePictureFromJob/{id}", name="ajax_cto_removePictureFromJob", options={"expose" = true})
  * @Method("POST")
  */
 public function removePictureFromJobAction(JobPicture $picture)
 {
     $job = $picture->getJob();
     $s3 = $this->get("cto.aws.s3");
     if ($s3->remove($picture->getPath())) {
         /** @var EntityManager $em */
         $em = $this->getDoctrine()->getManager();
         $job->removePicture($picture);
         $em->remove($picture);
         $em->flush();
         return new JsonResponse(["status" => "ok"], 200);
     }
     return new JsonResponse(["status" => "fail"], 400);
 }