private function ExifContent::filterFieldsOnSettings in Exif 8.2
Same name and namespace in other branches
- 8 src/ExifContent.php \Drupal\exif\ExifContent::filterFieldsOnSettings()
Look for metadata fields in an entity type.
Parameters
string $entityType: The entity type name to be modified.
\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity to look for metadata fields.
Return value
array The list of metadata fields found in the entity.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
2 calls to ExifContent::filterFieldsOnSettings()
- ExifContent::checkTitle in src/
ExifContent.php - Allow to fill the title with exif data.
- ExifContent::entity_insert_update in src/
ExifContent.php - Main entry of the module.
File
- src/
ExifContent.php, line 116
Class
- ExifContent
- Class ExifContent make link between drupal content and file content.
Namespace
Drupal\exifCode
private function filterFieldsOnSettings($entityType, FieldableEntityInterface $entity) {
$result = [];
foreach ($entity
->getFieldDefinitions() as $fieldName => $fieldDefinition) {
if ($fieldDefinition instanceof FieldConfigInterface || ($fieldDefinition instanceof BaseFieldDefinition and $fieldName === 'title')) {
$settings = \Drupal::entityTypeManager()
->getStorage('entity_form_display')
->load($entityType . '.' . $entity
->bundle() . '.default')
->getComponent($fieldName)['settings'];
$exifField = NULL;
$mediaField = NULL;
$imageField = NULL;
$exifFieldSeparator = NULL;
if ($settings != NULL) {
if (array_key_exists('exif_field', $settings)) {
$exifField = $settings['exif_field'];
}
if (array_key_exists('exif_field_separator', $settings)) {
$exifFieldSeparator = $settings['exif_field_separator'];
}
if (array_key_exists('image_field', $settings)) {
$imageField = $settings['image_field'];
}
if (array_key_exists('media_generic', $settings)) {
$mediaField = $settings['media_generic'];
}
}
if (isset($exifField) && (isset($imageField) || isset($mediaField))) {
$element = [];
if ($exifField == 'naming_convention') {
$name = substr($fieldName, 6);
}
else {
$name = $exifField;
}
$element['metadata_field'] = $name;
if (isset($exifFieldSeparator) && strlen($exifFieldSeparator) > 0) {
$element['metadata_field_separator'] = $exifFieldSeparator;
}
if (!isset($imageField) && isset($mediaField)) {
$element['image_field'] = $mediaField;
}
else {
$element['image_field'] = $imageField;
}
$result[$fieldName] = $element;
}
}
}
return $result;
}