function HistoryUserTimestamp::init

Same name and namespace in other branches
  1. 9 core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php \Drupal\history\Plugin\views\field\HistoryUserTimestamp::init()
  2. 8.9.x core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php \Drupal\history\Plugin\views\field\HistoryUserTimestamp::init()
  3. 11.x core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php \Drupal\history\Plugin\views\field\HistoryUserTimestamp::init()

Overrides Node::init

File

core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php, line 33

Class

HistoryUserTimestamp
Field handler to display the marker for new content.

Namespace

Drupal\history\Plugin\views\field

Code

public function init(ViewExecutable $view, DisplayPluginBase $display, ?array &$options = NULL) {
  parent::init($view, $display, $options);
  if (\Drupal::currentUser()->isAuthenticated()) {
    $this->additional_fields['created'] = [
      'table' => 'node_field_data',
      'field' => 'created',
    ];
    $this->additional_fields['changed'] = [
      'table' => 'node_field_data',
      'field' => 'changed',
    ];
    if (\Drupal::moduleHandler()->moduleExists('comment') && !empty($this->options['comments'])) {
      $this->additional_fields['last_comment'] = [
        'table' => 'comment_entity_statistics',
        'field' => 'last_comment_timestamp',
      ];
    }
  }
}

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