function NodeViewsHooks::viewsDataAlter

Implements hook_views_data_alter().

Attributes

#[Hook('views_data_alter', order: Order::First)]

File

core/modules/node/src/Hook/NodeViewsHooks.php, line 23

Class

NodeViewsHooks
Views hook implementations for node.

Namespace

Drupal\node\Hook

Code

public function viewsDataAlter(array &$data) : void {
  $data['users_field_data']['uid']['relationship'] = [
    'title' => $this->t('Content authored'),
    'help' => $this->t('Relate content to the user who created it. This relationship will create one record for each content item created by the user.'),
    'id' => 'standard',
    'base' => 'node_field_data',
    'base field' => 'uid',
    'field' => 'uid',
    'label' => $this->t('nodes'),
  ];
  $data['users_field_data']['uid_representative'] = [
    'relationship' => [
      'title' => $this->t('Representative node'),
      'label' => $this->t('Representative node'),
      'help' => $this->t('Obtains a single representative node for each user, according to a chosen sort criterion.'),
      'id' => 'groupwise_max',
      'relationship field' => 'uid',
      'outer field' => 'users_field_data.uid',
      'argument table' => 'users_field_data',
      'argument field' => 'uid',
      'base' => 'node_field_data',
      'field' => 'nid',
      'relationship' => 'node_field_data:uid',
    ],
  ];
}

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