Example #1
0
 /**
  * Add movieComment
  *
  * @param MovieComment $movieComment
  *
  * @return Image
  */
 public function addMovieComment(MovieComment $movieComment)
 {
     if (!$movieComment->getImages()->contains($this)) {
         $movieComment->addImage($this);
     }
     $this->movieComments[] = $movieComment;
     return $this;
 }
 /**
  * Link movie comment to image
  *
  * @ApiDoc(
  *     views={"default", "movie-comment"},
  *     section="MovieComment API",
  *     statusCodes={
  *         204="Returned when successful",
  *         400="Returned when an error has occurred",
  *     }
  * )
  *
  * @Security("is_granted('ROLE_MOVIE_COMMENT_EDIT', movieComment) and is_granted('ROLE_IMAGE_VIEW', image)")
  *
  * @Route("movie-comments/{movieComment}/images/{image}", name="api_movie_comment_link_movie_comment_images", defaults={"_format": "json"}, methods={"LINK"})
  *
  * @param MovieComment $movieComment
  * @param Image $image
  * @return Response
  */
 public function linkMovieCommentImagesAction(MovieComment $movieComment, Image $image)
 {
     if ($movieComment->getImages()->contains($image)) {
         return new Response('', 204);
     }
     $movieComment->addImage($image);
     $image->addMovieComment($movieComment);
     $this->getDoctrine()->getManager()->flush();
     return new Response('', 204);
 }