@param Post    $post
@param Comment $comment

@return Controller
359496
public function dispatchCommentDeleteEvent(Post $post, Comment $comment)
    {
        $event = new LogCommentDeleteEvent($post, $comment);

        return $this->dispatch($event);
    }
881094
public function newAction($postid)
    {
        $post = $this->getPost($postid);

        $entity = new Comment();
        $form   = $this->createForm(new CommentType(), $entity);

        return array(
            'entity' => $entity,
            'post'   => $post,
            'form'   => $form->createView(),
        );
    }
886630
public function dispatchCommentOnAddEvent(CommentInterface $comment)
    {
        $event = new CommentOnAddEvent(
            $comment
        );

        $this
            ->eventDispatcher
            ->dispatch(ElcodiCommentEvents::COMMENT_ONADD, $event);

        return $this;
    }
620907
public function removeComment(Comment $comment)
    {
        if ($this->comments->contains($comment)) {
            $this->comments->removeElement($comment);
        }
    }
850943
public function show(string $comment, array $params = [])
    {
        $path = $this->buildCommentsPath($comment);

        return $this->get($path, $params);
    }
571518
public function doPostComment($data, $form)
    {
        // Load class and parent from data
        if (isset($data['ParentClassName'])) {
            $this->controller->setParentClass($data['ParentClassName']);
        }
        if (isset($data['ParentID']) && ($class = $this->controller->getParentClass())) {
            $this->controller->setOwnerRecord($class::get()->byID($data['ParentID']));
        }
        if (!$this->controller->getOwnerRecord()) {
            return $this->getRequestHandler()->httpError(404);
        }

        // cache users data
        $form->setSessionData([
            'UserData' => json_encode($data),
            'Comment' =>  $data['Comment']
        ]);

        // extend hook to allow extensions. Also see onAfterPostComment
        $this->controller->extend('onBeforePostComment', $form);

        // If commenting can only be done by logged in users, make sure the user is logged in
        if (!$this->controller->getOwnerRecord()->canPostComment()) {
            return Security::permissionFailure(
                $this->controller,
                _t(
                    'SilverStripe\\Comments\\Controllers\\CommentingController.PERMISSIONFAILURE',
                    "You're not able to post comments to this page. Please ensure you are logged in and have an "
                    . 'appropriate permission level.'
                )
            );
        }

        if ($member = Security::getCurrentUser()) {
            $form->Fields()->push(HiddenField::create('AuthorID', 'Author ID', $member->ID));
        }

        // What kind of moderation is required?
        switch ($this->controller->getOwnerRecord()->ModerationRequired) {
            case 'Required':
                $requireModeration = true;
                break;
            case 'NonMembersOnly':
                $requireModeration = empty($member);
                break;
            case 'None':
            default:
                $requireModeration = false;
                break;
        }

        $comment = Comment::create();
        $form->saveInto($comment);

        $comment->ParentID = $data['ParentID'];
        $comment->ParentClass = $data['ParentClassName'];

        $comment->AllowHtml = $this->controller->getOption('html_allowed');
        $comment->Moderated = !$requireModeration;

        // Save into DB, or call pre-save hooks to give accurate preview
        $usePreview = $this->controller->getOption('use_preview');
        $isPreview = $usePreview && !empty($data['IsPreview']);
        if ($isPreview) {
            $comment->extend('onBeforeWrite');
        } else {
            $comment->write();

            // extend hook to allow extensions. Also see onBeforePostComment
            $this->controller->extend('onAfterPostComment', $comment);
        }

        // we want to show a notification if comments are moderated
        if ($requireModeration && !$comment->IsSpam) {
            $this->getRequest()->getSession()->set('CommentsModerated', 1);
        }

        // clear the users comment since the comment was successful.
        if ($comment->exists()) {
            // Remove the comment data as it's been saved already.
            unset($data['Comment']);
        }

        // cache users data (name, email, etc to prepopulate on other forms).
        $form->setSessionData([
            'UserData' => json_encode($data),
        ]);

        // Find parent link
        if (!empty($data['ReturnURL'])) {
            $url = $data['ReturnURL'];
        } elseif ($parent = $comment->Parent()) {
            $url = $parent->Link();
        } else {
            return $this->controller->redirectBack();
        }

        // Given a redirect page exists, attempt to link to the correct anchor
        if ($comment->IsSpam) {
            // Link to the form with the error message contained
            $hash = $form->FormName();
        } elseif (!$comment->Moderated) {
            // Display the "awaiting moderation" text
            $hash = 'moderated';
        } else {
            // Link to the moderated, non-spam comment
            $hash = $comment->Permalink();
        }

        return $this->controller->redirect(Controller::join_links($url, "#{$hash}"));
    }
437512
public function setupPost($post)
    {

        $user    = new User($this->db);
        $comment = new Comment($this->db);
        $vote    = new Vote($this->db);

        $post->img      = $user->getGravatar($post->user);
        $post->comments = $comment->getComments("parentId = ?", [$post->id]);
        $post->vote     = $vote->getVote("parentId = ? AND parentType = ?", [$post->id, "post"]);
        $post->markdown = $this->getMD($post->text);

        return $post;
    }
1153400
public function setComment($comment): self
    {
        if (!empty($comment)) {
            if (is_array($comment)) {
                $this->docComment->setLines($comment);
            } elseif (is_string($comment)) {
                $this->docComment->setString($comment);
            }
        }

        return $this;
    }
718565
public function sendCommentSpamRequestMail( $comment, $updatePath ) {

		$siteName		= $this->coreProperties->getSiteName();
		$fromEmail		= $this->mailProperties->getSenderEmail();
		$fromName		= $this->mailProperties->getSenderName();
		$contactEmail	= $this->mailProperties->getContactEmail();

		// Send Mail
		$this->getMailer()->compose( self::MAIL_COMMENT_SPAM_REQUEST, [ 'coreProperties' => $this->coreProperties, 'comment' => $comment, 'updatePath' => $updatePath ] )
			->setTo( $contactEmail )
			->setFrom( [ $fromEmail => "$fromName | $siteName" ] )
			->setSubject( "Spam Request | " . $this->coreProperties->getSiteName() )
			//->setTextBody( "heroor" )
			->send();
	}
160226
public function onAfterPostComment(Comment $comment)
    {
        $parent = $comment->Parent();

        if (!$parent || !$parent->hasMethod('notificationRecipients')) {
            return;
        }

        // Ask parent to submit all recipients
        $recipients = $parent->notificationRecipients($comment);

        foreach ($recipients as $recipient) {
            $this->notifyCommentRecipient($comment, $parent, $recipient);
        }
    }
481732
public function save(Comment $comment, Request $request)
    {
        $comment
            ->fill($request->get('comment'))
            ->save();

        Alert::info(__('Comment was saved'));

        return redirect()->route('platform.systems.comments');
    }
594885
public static function instance($postId, $title, $body, Author $author, array $comments)
    {
        $post = new self();

        $post->postId   = $postId;
        $post->title    = $title;
        $post->body     = $body;
        $post->author   = $author;
        $post->comments = $comments;

        return $post;
    }
185824
public function delete($commentid) {
        global $DB, $USER;
        $candelete = has_capability('moodle/comment:delete', $this->context);
        if (!$comment = $DB->get_record('comments', array('id'=>$commentid))) {
            throw new comment_exception('dbupdatefailed');
        }
        if (!($USER->id == $comment->userid || !empty($candelete))) {
            throw new comment_exception('nopermissiontocomment');
        }
        $DB->delete_records('comments', array('id'=>$commentid));
        // Trigger comment delete event.
        if (core_component::is_core_subsystem($this->component)) {
            $eventclassname = '\\core\\event\\' . $this->component . '_comment_deleted';
        } else {
            $eventclassname = '\\' . $this->component . '\\event\comment_deleted';
        }
        if (class_exists($eventclassname)) {
            $event = $eventclassname::create(
                    array(
                        'context' => $this->context,
                        'objectid' => $commentid,
                        'other' => array(
                            'itemid' => $this->itemid
                            )
                        ));
            $event->add_record_snapshot('comments', $comment);
            $event->trigger();
        }
        return true;
    }
627805
public function check($val, $comment = "")
	{
		$this->commonComment = trim($comment) . " ";
		$this->val = $val;
		$this->isValid = true;
		return $this;
	}
97199
public function deleteComment($commentId)
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the success response code.
		$this->oauth->setOption('success_code', 204);

		// Set the API base
		$base = '/v1/comments/' . $commentId;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'DELETE', $parameters);

		return $response;
	}
397490
public static function create($comment) {
    $comment = trim($comment);
    $nl_count = substr_count($comment, "\n");
    if ($nl_count > 1) {
      return LineCommentBlockNode::create($comment);
    }
    else {
      return new CommentNode(T_COMMENT, '// ' . $comment . "\n");
    }
  }
1249203
public function update(CommentRequest $request, Comment $comment)
    {
        try {
            $attributes = $request->all();

            $comment->update($attributes);
            return $this->response->message(trans('messages.success.updated', ['Module' => trans('news::comment.name')]))
                ->code(204)
                ->status('success')
                ->url(guard_url('news/comment/' . $comment->getRouteKey()))
                ->redirect();
        } catch (Exception $e) {
            return $this->response->message($e->getMessage())
                ->code(400)
                ->status('error')
                ->url(guard_url('news/comment/' . $comment->getRouteKey()))
                ->redirect();
        }

    }