You are here

public function FlagListItemViewsData::getViewsData in Flag Lists 8

Same name and namespace in other branches
  1. 4.0.x src/Entity/FlagListItemViewsData.php \Drupal\flag_lists\Entity\FlagListItemViewsData::getViewsData()

Returns views data for the entity type.

Return value

array Views data in the format of hook_views_data().

Overrides EntityViewsData::getViewsData

File

src/Entity/FlagListItemViewsData.php, line 15

Class

FlagListItemViewsData
Provides Views data for Flag list item entities.

Namespace

Drupal\flag_lists\Entity

Code

public function getViewsData() {
  $data = parent::getViewsData();

  // Additional information for Views integration, such as table joins,
  // can be put here.
  //
  // Connect the Flag List used.
  $data['flag_list_item_field_data']['flag_list'] = [
    'title' => t('Flagging collection'),
    'help' => t('The related Flagging collection'),
    'field' => [
      'id' => 'standard',
    ],
    'relationship' => [
      'base' => 'flagging_collection_field_data',
      'base field' => 'id',
      'id' => 'standard',
      'label' => t('Connected flag'),
    ],
  ];

  // Connect the Entity Flagged.
  $data['flag_list_item_field_data']['entity_id'] = [
    'title' => t('Node'),
    'help' => t('The related Node'),
    'field' => [
      'id' => 'standard',
    ],
    'relationship' => [
      'base' => 'node_field_data',
      'base field' => 'nid',
      'id' => 'standard',
      'label' => t('Connected node'),
    ],
  ];
  return $data;
}