/** * Edits the content of a comment * * @param void * @return ViewModel * @throws AccessProhibitedException **/ public function editAction() { $this->_checkAcl('edit'); $comment = $this->_service->getOne($this->getRequest()->getQuery('id')); $form = new CommentForm(); $form->bind($comment); $form->remove('parentId'); $form->remove('captcha'); $form->get('comment')->setAttribute('id', 'commentEditor'); $form->get('comment')->setAttribute('class', 'ckeditor'); $form->get('submit')->setValue('Save'); $this->_service->setForm($form); if ($this->getRequest()->isPost()) { $this->_service->edit($this->getRequest()->getPost()); } return new ViewModel(array('form' => $form, 'messages' => $this->_service->getMessages(CommentService::MSG_NOTICE), 'errors' => $this->_service->getMessages(CommentService::MSG_ERROR))); }
/** * 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); }