You are here

protected function TabularBaseYamlFormExporter::getFieldDefinitions in YAML Form 8

Get a form's field definitions.

Return value

array An associative array containing a form's field definitions.

2 calls to TabularBaseYamlFormExporter::getFieldDefinitions()
TabularBaseYamlFormExporter::buildHeader in src/Plugin/YamlFormExporter/TabularBaseYamlFormExporter.php
Build export header using form submission field definitions and form element columns.
TabularBaseYamlFormExporter::buildRecord in src/Plugin/YamlFormExporter/TabularBaseYamlFormExporter.php
Build export record using a form submission.

File

src/Plugin/YamlFormExporter/TabularBaseYamlFormExporter.php, line 161

Class

TabularBaseYamlFormExporter
Defines abstract tabular exporter used to build CSV files and HTML tables.

Namespace

Drupal\yamlform\Plugin\YamlFormExporter

Code

protected function getFieldDefinitions() {
  if (isset($this->fieldDefinitions)) {
    return $this->fieldDefinitions;
  }
  $export_options = $this
    ->getConfiguration();
  $this->fieldDefinitions = $this->entityStorage
    ->getFieldDefinitions();
  $this->fieldDefinitions = array_diff_key($this->fieldDefinitions, $export_options['excluded_columns']);

  // Add custom entity reference field definitions which rely on the
  // entity type and entity id.
  if ($export_options['entity_reference_format'] == 'link' && isset($this->fieldDefinitions['entity_type']) && isset($this->fieldDefinitions['entity_id'])) {
    $this->fieldDefinitions['entity_title'] = [
      'name' => 'entity_title',
      'title' => t('Submitted to: Entity title'),
      'type' => 'entity_title',
    ];
    $this->fieldDefinitions['entity_url'] = [
      'name' => 'entity_url',
      'title' => t('Submitted to: Entity URL'),
      'type' => 'entity_url',
    ];
  }
  return $this->fieldDefinitions;
}