You are here

public function HistoryUserTimestamp::init in Drupal 8

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()

Initialize the plugin.

Parameters

\Drupal\views\ViewExecutable $view: The view object.

\Drupal\views\Plugin\views\display\DisplayPluginBase $display: The display handler.

array $options: The options configured for this plugin.

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',
      ];
    }
  }
}