getCommentRepository()->get($id); $topic = $this->getTopicRepository()->get($comment->topic_id); $category = $this->getCategoryRepository()->get($topic->category_id); if (!$this->getCommentAccessChecker()->canDelete($topic->category_id, $comment->created_by)) { throw new Forbidden(); } $this->getCommentRepository()->get($id)->delete(); $this->response->redirect('/' . $category->slug . '/' . $topic->slug); } private function getCommentAccessChecker(): CommentAccessChecker { return new CommentAccessChecker(); } private function getTopicRepository(): TopicWriteRepository { return new TopicWriteRepository(); } private function getCommentRepository(): CommentWriteRepository { return new CommentWriteRepository(); } private function getCategoryRepository(): CategoryWriteRepository { return new CategoryWriteRepository(); } }