function exif_entity_presave in Exif 8
Same name and namespace in other branches
- 8.2 exif.module \exif_entity_presave()
Implements hook_entity_presave().
Calculate the value for each metadata field so they can be stored correctly.
File
- ./
exif.module, line 58 - Entry point for exif module.
Code
function exif_entity_presave(EntityInterface $entity) {
$entityType = '';
if ($entity instanceof NodeInterface) {
$entityType = 'node';
}
else {
if (Drupal::moduleHandler()
->moduleExists("media_entity") && $entity instanceof MediaInterface) {
$entityType = 'media';
}
}
if ($entityType != '') {
$config = Drupal::configFactory()
->get('exif.settings');
$shouldUpdateMetadata = $config
->get('update_metadata');
if (!isset($shouldUpdateMetadata)) {
$shouldUpdateMetadata = TRUE;
}
$inserting = !isset($entity->original);
if ($inserting || $shouldUpdateMetadata) {
$exifContentHandler = new ExifContent();
$exifContentHandler
->entity_insert_update($entityType, $entity);
}
}
}