privilegeService = $privilegeService; $this->postService = $postService; $this->commentService = $commentService; $this->commentViewProxy = $commentViewProxy; $this->postViewProxy = $postViewProxy; $this->inputReader = $inputReader; } public function getMethods() { return ['PUT']; } public function getUrl() { return '/api/comments/:commentId'; } public function work($args) { $comment = $this->commentService->getById($args['commentId']); $this->privilegeService->assertPrivilege( ($comment->getUser() && $this->privilegeService->isLoggedIn($comment->getUser())) ? Privilege::EDIT_OWN_COMMENTS : Privilege::EDIT_ALL_COMMENTS); $comment = $this->commentService->updateComment($comment, $this->inputReader->text); return $this->commentViewProxy->fromEntity($comment, $this->getCommentsFetchConfig()); } }