class LastTimestamp

Same name and namespace in other branches
  1. 11.x core/modules/comment/src/Plugin/views/field/LastTimestamp.php \Drupal\comment\Plugin\views\field\LastTimestamp
  2. 10 core/modules/comment/src/Plugin/views/field/LastTimestamp.php \Drupal\comment\Plugin\views\field\LastTimestamp
  3. 8.9.x core/modules/comment/src/Plugin/views/field/LastTimestamp.php \Drupal\comment\Plugin\views\field\LastTimestamp

Field handler to display the timestamp of a comment with the count of comments.

Plugin annotation

@ViewsField("comment_last_timestamp");

Hierarchy

Expanded class hierarchy of LastTimestamp

Related topics

File

core/modules/comment/src/Plugin/views/field/LastTimestamp.php, line 17

Namespace

Drupal\comment\Plugin\views\field
View source
class LastTimestamp extends Date {
  
  /**
   * {@inheritdoc}
   */
  public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    parent::init($view, $display, $options);
    $this->additional_fields['comment_count'] = 'comment_count';
  }
  
  /**
   * {@inheritdoc}
   */
  public function render(ResultRow $values) {
    $comment_count = $this->getValue($values, 'comment_count');
    if (empty($this->options['empty_zero']) || $comment_count) {
      return parent::render($values);
    }
    else {
      return NULL;
    }
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.