/** * @Route("/{id}/review/new", name="article_new_review") * @Template("frontend/Article/new.html.twig") * @Security("is_granted('UPLOAD_NEW_ARTICLE_REVIEW', article)") * Función para enviar una nueva versión de un artículo */ public function newReviewAction(Article $article, Request $request) { $conference = $article->getInscription()->getConference(); $user = $this->getUser(); $inscription = $this->getDoctrine()->getRepository('AppBundle:Inscription')->findOneBy(array('conference' => $conference, 'user' => $user)); if (!$inscription) { $this->addFlash('alert', $this->get('translator')->trans('You are not registered in this conference')); return $this->redirectToRoute('conference_show'); } $articles = $this->getDoctrine()->getRepository('AppBundle:Article')->findOneBy(array('id' => $article->getId())); $form = $this->createForm(new ArticleType(), $articles); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($article); $em->flush(); $article_review = new ArticleReview(); $article_review->setArticle($article); $article_review->setPath($form->get('path')->getData()); $em = $this->getDoctrine()->getManager(); $em->persist($article_review); $uploadableManager = $this->get('stof_doctrine_extensions.uploadable.manager'); $uploadableManager->markEntityToUpload($article_review, $article_review->getPath()); $em->flush(); $this->get('session')->getFlashBag()->set('success', $this->get('translator')->trans('Your new article has been successfully send')); return $this->redirectToRoute('article_list'); } return ['conference' => $conference, 'form' => $form->createView()]; }