Esempio n. 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);
 }
Esempio n. 2
0
 /**
  * @param JobPicture $picture
  * @return CarJob
  */
 public function addPicture(JobPicture $picture)
 {
     $picture->setJob($this);
     $this->pictures->add($picture);
     return $this;
 }