/** * @Route("/new", name="article_new") * @Template("frontend/Article/new.html.twig") * Función para enviar un nuevo artículo a una conferencia */ public function newAction(Request $request) { $user = $this->getUser(); $conference = $this->getConference(); $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'); } $article = new Article(); $article->setInscription($inscription); $form = $this->createForm(new ArticleType(), $article); $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->addFlash('success', $this->get('translator')->trans('Your article has been successfully uploaded')); return $this->redirectToRoute('article_list'); } return ['conference' => $conference, 'form' => $form->createView()]; }
/** * @Given /^I submitted the following articles to "([^".]*)":$/ */ public function iSubmittedTheFollowing($name, TableNode $tableNode) { $em = $this->getEntityManager(); foreach ($tableNode->getHash() as $articleHash) { $articles = new Article(); $articles->setTitle($articleHash['title']); $articles->setKeyword($articleHash['keyword']); $articles->setAbstract($articleHash['abstract']); $articles->setStateEnd($articleHash['stateEnd']); $articles->setInscription($this->findInscription($name)); $em->persist($articles); } $em->flush(); }