protected function buildDomainObject($row)
 {
     $comment = new Comment();
     $comment->setId($row['com_id']);
     $comment->setContent($row['com_content']);
     if (array_key_exists('tacos_id', $row)) {
         // Find and set the associated article
         $tacosId = $row['tacos_id'];
         $tacos = $this->tacosDAO->find($tacosId);
         $comment->setTacos($tacos);
     }
     if (array_key_exists('usr_id', $row)) {
         // Find and set the associated author
         $userId = $row['usr_id'];
         $user = $this->userDAO->find($userId);
         $comment->setAuthor($user);
     }
     return $comment;
 }
 public function tacosAction($id, Request $request, Application $app)
 {
     $tacos = $app['dao.tacos']->find($id);
     $comments = $app['dao.comment']->findAllByTacos($id);
     $commentFormView = null;
     if ($app['security.authorization_checker']->isGranted('IS_AUTHENTICATED_FULLY')) {
         $comment = new Comment();
         $comment->setTacos($tacos);
         $user = $app['user'];
         $comment->setAuthor($user);
         $commentForm = $app['form.factory']->create(new CommentType(), $comment);
         $commentForm->handleRequest($request);
         if ($commentForm->isSubmitted() && $commentForm->isValid()) {
             $app['dao.comment']->save($comment);
             $app['session']->getFlashBag()->add('success', 'Votre commentaire a été ajouté avec succès !');
         }
         $commentFormView = $commentForm->createView();
     }
     return $app['twig']->render('tacos.html.twig', array('tacos' => $tacos, 'comments' => $comments, 'commentForm' => $commentFormView));
 }