bbae18d54fdb88461dd5098315859fdd8ee9279b
[yaffs-website] / web / core / modules / comment / src / Plugin / views / field / LastTimestamp.php
1 <?php
2
3 namespace Drupal\comment\Plugin\views\field;
4
5 use Drupal\views\Plugin\views\field\Date;
6 use Drupal\views\Plugin\views\display\DisplayPluginBase;
7 use Drupal\views\ResultRow;
8 use Drupal\views\ViewExecutable;
9
10 /**
11  * Field handler to display the timestamp of a comment with the count of comments.
12  *
13  * @ingroup views_field_handlers
14  *
15  * @ViewsField("comment_last_timestamp")
16  */
17 class LastTimestamp extends Date {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
23     parent::init($view, $display, $options);
24
25     $this->additional_fields['comment_count'] = 'comment_count';
26   }
27
28   /**
29    * {@inheritdoc}
30    */
31   public function render(ResultRow $values) {
32     $comment_count = $this->getValue($values, 'comment_count');
33     if (empty($this->options['empty_zero']) || $comment_count) {
34       return parent::render($values);
35     }
36     else {
37       return NULL;
38     }
39   }
40
41 }