WebformExcludedColumns.php in Webform 8.5
File
src/Element/WebformExcludedColumns.php
View source
<?php
namespace Drupal\webform\Element;
use Drupal\webform\Entity\Webform as WebformEntity;
class WebformExcludedColumns extends WebformExcludedBase {
public static function getWebformExcludedHeader() {
return [
'title' => t('Title'),
'name' => t('Name'),
'type' => t('Date type/Element type'),
];
}
public static function getWebformExcludedOptions(array $element) {
$webform = WebformEntity::load($element['#webform_id']) ?: \Drupal::service('webform.request')
->getCurrentWebform();
if (!$webform) {
return [];
}
$options = [];
$submission_storage = \Drupal::entityTypeManager()
->getStorage('webform_submission');
$field_definitions = $submission_storage
->getFieldDefinitions();
$field_definitions = $submission_storage
->checkFieldDefinitionAccess($webform, $field_definitions);
foreach ($field_definitions as $key => $field_definition) {
$options[$key] = [
'title' => $field_definition['title'],
'name' => $key,
'type' => $field_definition['type'],
];
}
$elements = $webform
->getElementsInitializedFlattenedAndHasValue('view');
$token_manager = \Drupal::service('webform.token_manager');
$elements = $token_manager
->replace($elements, $webform);
foreach ($elements as $key => $element) {
$options[$key] = [
'title' => $element['#admin_title'] ?: $element['#title'] ?: $key,
'name' => $key,
'type' => isset($element['#type']) ? $element['#type'] : '',
];
}
return $options;
}
}