You are here

public function WebformEntityReferenceViews::getElementViewsData in Webform Views Integration 8.5

Generate views data definition that corresponds to given webform element.

Parameters

\Drupal\webform\Plugin\WebformElementInterface $element_plugin: Webform element plugin whose views data definition is requested

array $element: Webform element whose views data definition is requested

Return value

array Views data definition array that corresponds to the given webform element. The structure of this array should have the following structure:

  • field: (array) Views data 'field' section to use for this webform element
  • filter: (array) Views data 'filter' section to use for this webform element
  • sort: (array) Views data 'sort' section to use for this webform element
  • TODO: Do you need more here?

Overrides WebformDefaultViews::getElementViewsData

1 call to WebformEntityReferenceViews::getElementViewsData()
WebformEntityReferenceSelectViews::getElementViewsData in src/WebformElementViews/WebformEntityReferenceSelectViews.php
Generate views data definition that corresponds to given webform element.
1 method overrides WebformEntityReferenceViews::getElementViewsData()
WebformEntityReferenceSelectViews::getElementViewsData in src/WebformElementViews/WebformEntityReferenceSelectViews.php
Generate views data definition that corresponds to given webform element.

File

src/WebformElementViews/WebformEntityReferenceViews.php, line 72

Class

WebformEntityReferenceViews
Webform views handler for entity reference webform elements.

Namespace

Drupal\webform_views\WebformElementViews

Code

public function getElementViewsData(WebformElementInterface $element_plugin, array $element) {
  $views_data = parent::getElementViewsData($element_plugin, $element);
  $target_entity_type = $this
    ->getTargetEntityType($element_plugin, $element);
  if ($target_entity_type instanceof ContentEntityTypeInterface) {
    $views_data['relationship'] = [
      'base' => $target_entity_type
        ->getDataTable() ? $target_entity_type
        ->getDataTable() : $target_entity_type
        ->getBaseTable(),
      'field' => 'value',
      'base field' => $target_entity_type
        ->getKey('id'),
      'label' => $target_entity_type
        ->getLabel(),
      'title' => $this
        ->t('Referenced @entity_label', [
        '@entity_label' => $target_entity_type
          ->getLabel(),
      ]),
      'id' => 'standard',
    ];
  }
  return $views_data;
}