You are here

public function EntityExportCsvManager::getBundleFields in Entity Export CSV 8

Get the fields as options given an entity type and a bundle.

Parameters

string $entity_type_id: The entity type id.

string $bundle: The bundle.

bool $return_field_definition: Return the field definitions or label.

Return value

array|\Drupal\Core\Field\FieldDefinitionInterface[] An array of field label or field definition, keyed by the field name.

Overrides EntityExportCsvManagerInterface::getBundleFields

1 call to EntityExportCsvManager::getBundleFields()
EntityExportCsvManager::getBundleFieldsEnabled in src/EntityExportCsvManager.php
Get the fields enabled as options given an entity type and a bundle.

File

src/EntityExportCsvManager.php, line 248

Class

EntityExportCsvManager
Class EntityExportCsvManager.

Namespace

Drupal\entity_export_csv

Code

public function getBundleFields($entity_type_id, $bundle, $return_field_definition = FALSE) {
  $options = [];
  $fields = $this
    ->getBundleFieldDefinitions($entity_type_id, $bundle);
  foreach ($fields as $field_name => $field_definition) {
    if ($return_field_definition) {
      $options[$field_name] = $field_definition;
    }
    else {
      $options[$field_name] = $field_definition
        ->getLabel();
    }
  }
  $event = new EntityExportCsvFieldsSupportedEvent($options, $entity_type_id, $bundle, $return_field_definition);
  $this->eventDispatcher
    ->dispatch(EntityExportCsvEvents::ENTITY_EXPORT_CSV_FIELDS_SUPPORTED, $event);
  $options = $event
    ->getFields();
  return $options;
}