public function handleRemove() { $this->userPermissionCheck('remove'); try { $this->commentFacade->remove($this->comment); } catch (ActionFailedException $e) { $this->refresh('page.comments.actions.remove.messages.error', FlashMessage::ERROR); } $this->onSuccessCommentRemoval($this->comment); $this->redirect('this#comments'); }
public function processForm(Form $form, $values) { if ($this->page->getAllowedComments() === false and !$this->authorizator->isAllowed($this->user, 'page_comment_form', 'comment_on_closed')) { $this->flashMessage('page.comments.form.messages.closedComments', FlashMessage::WARNING); $this->redirect('this#comments'); } $values['page'] = $this->page; try { $comment = $this->commentFacade->save((array) $values); $this->flashMessage('page.comments.form.messages.success', FlashMessage::SUCCESS); $this->redirect('this#comment-' . $comment->getId()); } catch (ActionFailedException $e) { $form->addError($this->translator->translate('page.comments.form.messages.error')); } }
/** * @param $commentId * @return Comment|null */ private function getComment($commentId) { return $this->commentFacade->fetchComment((new CommentQuery())->byId($commentId)->byPage($this->page)->indexedById()); }