Ejemplo n.º 1
0
 /**
  * @Route("/", name="homepage")
  */
 public function indexAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $articles = $em->getRepository('AppBundle:Article')->findAll();
     $article = new Article();
     $user = new User();
     $authors = array();
     foreach ($articles as $article) {
         if ($article->getArticleOwner() == 0) {
             $authors[0] = "admin";
         } else {
             $user = $em->getRepository("AppBundle:User")->find($article->getArticleOwner());
             $authors[$user->getID()] = $user->getUsername();
         }
     }
     $form = $this->createFormBuilder()->add('commentContent', TextareaType::class)->getForm();
     return $this->render('default/index.html.twig', array('pageTitle' => 'Main Page', 'articles' => $articles, 'authors' => $authors, 'commentForm' => $form->createView()));
 }