Ejemplo n.º 1
0
 /**
  * To view a specific blog post
  *
  * @param void
  * @return ViewModel
  * @throws AccessProhibitedException
  **/
 public function viewAction()
 {
     $this->_checkAcl('view');
     $request = $this->getRequest();
     $post = $this->_postService->getFromTitle($request->getQuery('title'));
     $form = new CommentForm();
     $form->setReplyToList($post->getComments());
     $viewVars = array();
     if ($request->isPost()) {
         $service = new CommentService($this->_em);
         $service->setForm($form);
         $service->setPost($post);
         $service->save($request->getPost());
         $viewVars['messages'] = $service->getMessages(CommentService::MSG_NOTICE);
         $viewVars['errors'] = $service->getMessages(CommentService::MSG_ERROR);
     }
     $viewVars['post'] = $post;
     $viewVars['form'] = $form;
     $viewVars['query'] = $request->getQuery();
     return new ViewModel($viewVars);
 }