public function FieldTypeExportManager::getFieldTypeOptions in Entity Export CSV 8
Get definition options for a given field type.
Parameters
string $field_type: The field type.
string $entity_type: The entity type id.
string $bundle: The bundle id.
string $field_name: The field name.
Return value
array An array of definition options.
Overrides FieldTypeExportManagerInterface::getFieldTypeOptions
File
- src/
Plugin/ FieldTypeExportManager.php, line 48
Class
- FieldTypeExportManager
- Provides the Field type export plugin manager.
Namespace
Drupal\entity_export_csv\PluginCode
public function getFieldTypeOptions($field_type, $entity_type = NULL, $bundle = NULL, $field_name = NULL) {
$options = [];
$definitions = $this
->getDefinitions();
$this
->sortDefinitions($definitions);
foreach ($definitions as $plugin_id => $definition) {
if (!isset($definition['field_type'])) {
continue;
}
if (in_array($field_type, $definition['field_type']) || empty($definition['field_type'])) {
if ($entity_type) {
if (!empty($definition['entity_type']) && !in_array($entity_type, $definition['entity_type'])) {
continue;
}
}
if ($bundle) {
if (!empty($definition['bundle']) && !in_array($bundle, $definition['bundle'])) {
continue;
}
}
if ($field_name) {
if (!empty($definition['field_name']) && !in_array($field_name, $definition['field_name'])) {
continue;
}
}
if (isset($definition['exclusive']) && $definition['exclusive'] === TRUE) {
return [
$plugin_id => $definition['label'],
];
}
$options[$plugin_id] = $definition['label'];
}
}
return $options;
}