request->getPost(); $user = $this->getLoginUser(); $validator = new UserLimitValidator(); $validator->checkDailyCommentLimit($user); $validator = new CommentValidator(); $item = $validator->checkItem($post['item_id'], $post['item_type']); $comment = new CommentModel(); $data = $this->handlePostData($post); $data['item_id'] = $post['item_id']; $data['item_type'] = $post['item_type']; $data['owner_id'] = $user->id; $data['published'] = $this->getPublishStatus($user); $comment->create($data); $this->incrUserDailyCommentCount($user); if ($comment->published == CommentModel::PUBLISH_APPROVED) { $this->incrItemCommentCount($item); $this->incrUserCommentCount($user); $this->handleItemCommentedNotice($item, $comment); $this->handleCommentPostPoint($comment); } $this->eventsManager->fire('Comment:afterCreate', $this, $comment); return $comment; } }