Same name and namespace in other branches
- 8.x-2.x src/ExifContent.php \Drupal\exif\ExifContent::checkTitle() 1 comment
Allow to fill the title with exif data.
Used in hook exif_entity_create.
Parameters
string $entityType: The entity type name to be modified.
\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity to look for metadata fields.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
-
src/
ExifContent.php, line 52
Class
- ExifContent
- Class ExifContent make link between drupal content and file content.
Namespace
Drupal\exifCode
public function checkTitle($entityType, FieldableEntityInterface $entity) {
$bundles_to_check = $this->getBundleForExifData();
if (in_array($entity->bundle(), $bundles_to_check)) {
$exif = ExifFactory::getExifInterface();
$ar_exif_fields = $this->filterFieldsOnSettings($entityType, $entity);
$ar_exif_fields = $exif->getMetadataFields($ar_exif_fields);
foreach ($ar_exif_fields as $drupal_field => $metadata_field_descriptor) {
$field_name = $drupal_field;
if ($field_name == 'title') {
$field = $entity->get($field_name);
if ($field->isEmpty()) {
$field->appendItem("EXIF_FILLED");
}
break;
}
}
}
}