You are here

public function EntityExportCsvManager::getBundleFieldsEnabled in Entity Export CSV 8

Get the fields enabled 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::getBundleFieldsEnabled

File

src/EntityExportCsvManager.php, line 268

Class

EntityExportCsvManager
Class EntityExportCsvManager.

Namespace

Drupal\entity_export_csv

Code

public function getBundleFieldsEnabled($entity_type_id, $bundle, $return_field_definition = FALSE) {
  $options = $this
    ->getBundleFields($entity_type_id, $bundle, $return_field_definition);
  $bundle_fields_settings = $this
    ->getConfiguration()
    ->get('entity_types.' . $entity_type_id . '.bundles.' . $bundle) ?: [];
  if (!empty($bundle_fields_settings)) {
    $options = array_intersect_key($options, $bundle_fields_settings);
  }
  $event = new EntityExportCsvFieldsEnabledEvent($options, $entity_type_id, $bundle, $return_field_definition);
  $this->eventDispatcher
    ->dispatch(EntityExportCsvEvents::ENTITY_EXPORT_CSV_FIELDS_ENABLE, $event);
  $options = $event
    ->getFields();
  return $options;
}