WebformManagedFileViews.php in Webform Views Integration 8.5
File
src/WebformElementViews/WebformManagedFileViews.php
View source
<?php
namespace Drupal\webform_views\WebformElementViews;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\webform\Plugin\WebformElementInterface;
use Drupal\webform\Plugin\WebformElementManagerInterface;
class WebformManagedFileViews extends WebformElementViewsAbstract {
protected $entityTypeManager;
public function __construct(EntityTypeManagerInterface $entity_type_manager, WebformElementManagerInterface $webform_element_manager) {
parent::__construct($entity_type_manager, $webform_element_manager);
$this->entityTypeManager = $entity_type_manager;
}
public function getElementViewsData(WebformElementInterface $element_plugin, array $element) {
$views_data = parent::getElementViewsData($element_plugin, $element);
if ($this->entityTypeManager
->hasDefinition('file')) {
$file = $this->entityTypeManager
->getDefinition('file');
$views_data['relationship'] = [
'base' => $file
->getDataTable() ? $file
->getDataTable() : $file
->getBaseTable(),
'field' => 'value',
'base field' => $file
->getKey('id'),
'label' => $this
->t('@element: File', [
'@element' => $element['#title'],
]),
'id' => 'standard',
];
}
return $views_data;
}
}