Пример #1
0
 /**
  * @Route("/album/{id}/comment", requirements={
  *     "id": "\d+"
  * })
  * @Method({"POST", "OPTIONS"})
  */
 public function commentAlbumAction(Request $request, Album $album)
 {
     $this->denyAccessUnlessGranted('comment', $album, 'You are not allowed to comment this album.');
     $text = $request->get('text');
     $comment = new AlbumComment();
     $comment->setText($text);
     $comment->setAuthor($this->getUser());
     $comment->setDate(new \DateTime());
     $album->addComment($comment);
     $validator = $this->get('validator');
     $errors = $validator->validate($album);
     if (count($errors) > 0) {
         return new JsonResponse(Util::violationListToJson($errors));
     }
     $em = $this->getDoctrine()->getManager();
     $em->persist($comment);
     $em->persist($album);
     $em->flush();
     return new JsonResponse($album->toJson());
 }
Пример #2
0
 protected function getEntityName()
 {
     return Util::getEntityFullName(\substr($this->getShortName(), 0, -10));
 }
Пример #3
0
 protected function getEntityClassName()
 {
     return Util::getEntityFullName($this->getName());
 }
Пример #4
0
 /**
  * @param mixed $language
  */
 public function setLanguage($language)
 {
     $this->language = $language;
     $this->slug = Util::getSlug($language);
 }