LastTimestamp.php 804 Bytes
Newer Older
1 2 3 4 5 6 7
<?php

/**
 * @file
 * Definition of views_handler_field_last_comment_timestamp.
 */

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 17
/**
 * Field handler to display the timestamp of a comment with the count of comments.
 *
 * @ingroup views_field_handlers
 */
dawehner's avatar
dawehner committed
18 19 20 21 22 23 24

/**
 * @Plugin(
 *   plugin_id = "comment_last_timestamp"
 * )
 */
class LastTimestamp extends Date {
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
  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;
    }
  }
}