public function FieldTypeExportBase::getHeaders in Entity Export CSV 8
Get the header columns for a field.
Parameters
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.
Return value
array An array of header columns.
Overrides FieldTypeExportInterface::getHeaders
File
- src/
Plugin/ FieldTypeExportBase.php, line 457
Class
- FieldTypeExportBase
- Base class for Field type export plugins.
Namespace
Drupal\entity_export_csv\PluginCode
public function getHeaders(FieldDefinitionInterface $field_definition) {
$headers = [];
$columns = $this
->getColumns($field_definition);
$header_label = $this
->getHeaderLabel($field_definition);
$properties_selected = $this
->getPropertiesSelected($field_definition);
if ($columns === 1) {
if ($this
->propertiesInSeparateColumns()) {
foreach ($properties_selected as $property_name) {
$headers[] = $header_label . '__' . $this
->getPropertyLabel($property_name, $field_definition);
}
}
else {
$headers[] = $header_label;
}
}
else {
for ($i = 0; $i < $columns; $i++) {
if ($this
->propertiesInSeparateColumns()) {
foreach ($properties_selected as $property_name) {
$headers[] = $header_label . '__' . $this
->getPropertyLabel($property_name, $field_definition) . '__' . $i;
}
}
else {
$headers[$i] = $header_label . '__' . $i;
}
}
}
return $headers;
}