LastTimestamp.php 822 Bytes
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Definition of Views\comment\Plugin\views\field\LastTimestamp.
6 7
 */

8
namespace Views\comment\Plugin\views\field;
dawehner's avatar
dawehner committed
9

10
use Drupal\views\Plugin\views\field\Date;
dawehner's avatar
dawehner committed
11 12
use Drupal\Core\Annotation\Plugin;

13 14 15 16
/**
 * Field handler to display the timestamp of a comment with the count of comments.
 *
 * @ingroup views_field_handlers
17
 *
dawehner's avatar
dawehner committed
18
 * @Plugin(
19 20
 *   id = "comment_last_timestamp",
 *   module = "comment"
dawehner's avatar
dawehner committed
21 22 23
 * )
 */
class LastTimestamp extends Date {
24

25 26 27 28 29 30 31 32 33 34 35 36 37 38
  function construct() {
    parent::construct();
    $this->additional_fields['comment_count'] = 'comment_count';
  }

  function render($values) {
    $comment_count = $this->get_value($values, 'comment_count');
    if (empty($this->options['empty_zero']) || $comment_count) {
      return parent::render($values);
    }
    else {
      return NULL;
    }
  }
39

40
}