/** * Event details controller. * * @param integer $id Event id * @param Request $request Incoming request * @param Application $app Silex application */ public function eventAction($id, Request $request, Application $app) { $event = $app['dao.event']->find($id); $types = $app['dao.type']->findAll(); $commentFormView = null; $ticketFormView = null; $user = $app['user']; if ($app['security.authorization_checker']->isGranted('IS_AUTHENTICATED_FULLY')) { // A user is fully authenticated : he can add comments and commands $ticket = new Ticket(); $ticket->setEvent($event); $ticketForm = $app['form.factory']->create(new TicketType(), $ticket); $ticketForm->handleRequest($request); if ($ticketForm->isSubmitted() && $ticketForm->isValid()) { $app['dao.ticket']->save($ticket, $user); $app['session']->getFlashBag()->add('success', 'Your command was succesfully added.'); } $ticketFormView = $ticketForm->createView(); $comment = new Commentary(); $comment->setEvent($event); $comment->setUser($user); $commentForm = $app['form.factory']->create(new CommentType(), $comment); $commentForm->handleRequest($request); if ($commentForm->isSubmitted() && $commentForm->isValid()) { $app['dao.commentary']->save($comment); $app['session']->getFlashBag()->add('success', 'Your comment was succesfully added.'); } $commentFormView = $commentForm->createView(); } $comments = $app['dao.commentary']->findAllByEvent($id); return $app['twig']->render('event.html.twig', array('event' => $event, 'comments' => $comments, 'types' => $types, 'commentForm' => $commentFormView, 'ticketForm' => $ticketFormView)); }
/** * Creates a Ticket object based on a DB row. * * @param array $row The DB row containing Ticket data. * @return \MicroCMS\Domain\Ticket */ protected function buildDomainObject($row) { $ticket = new Ticket(); $ticket->setNum($row['num_ticket']); $event_id = $row['num_event']; //$event = $this->eventDAO->find($event_id); //$eventDAO = new EventDAO($this->getDb()); $event = $this->findEvent($event_id); $ticket->setEvent($event); $ticket->setNumPlace($row['numPlace_ticket']); return $ticket; }