You are here

protected function WebformSubmissionViewsData::getWebformElementViewsData in Webform Views Integration 8.5

Collect webform element views data.

Parameters

array $element: Element whose views data is to be collected

\Drupal\webform\WebformInterface $webform: Webform where $element belongs to

Return value

array Views data that corresponds to the provided $element

1 call to WebformSubmissionViewsData::getWebformElementViewsData()
WebformSubmissionViewsData::getViewsData in src/WebformSubmissionViewsData.php
Returns views data for the entity type.

File

src/WebformSubmissionViewsData.php, line 234

Class

WebformSubmissionViewsData
Views data for 'webform_submission' entity type.

Namespace

Drupal\webform_views

Code

protected function getWebformElementViewsData($element, WebformInterface $webform) {
  $data = [];
  $element_plugin = $this->webformElementManager
    ->getElementInstance($element);
  if (isset($element_plugin
    ->getPluginDefinition()['webform_views_handler'])) {
    $views_handler_class = $element_plugin
      ->getPluginDefinition()['webform_views_handler'];
    $this->moduleHandler
      ->alter('webform_views_element_views_handler', $views_handler_class, $element, $webform);
    if (is_subclass_of($views_handler_class, ContainerInjectionInterface::class)) {
      $views_handler = $views_handler_class::create(\Drupal::getContainer());
    }
    else {
      $views_handler = new $views_handler_class();
    }
    $data = $views_handler
      ->getViewsData($element, $webform);
  }
  return $data;
}