PublishComment.php

Contains \Drupal\comment\Plugin\Action\PublishComment.

Namespace

Drupal\comment\Plugin\Action

File

drupal/core/modules/comment/lib/Drupal/comment/Plugin/Action/PublishComment.php
View source
<?php

/**
 * @file
 * Contains \Drupal\comment\Plugin\Action\PublishComment.
 */
namespace Drupal\comment\Plugin\Action;

use Drupal\Core\Annotation\Action;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Action\ActionBase;

/**
 * Publishes a comment.
 *
 * @Action(
 *   id = "comment_publish_action",
 *   label = @Translation("Publish comment"),
 *   type = "comment"
 * )
 */
class PublishComment extends ActionBase {

  /**
   * {@inheritdoc}
   */
  public function execute($comment = NULL) {
    $comment->status->value = COMMENT_PUBLISHED;
    $comment
      ->save();
  }

}

Classes

Namesort descending Description
PublishComment Publishes a comment.