protected function ExifSettingsController::addFields in Exif 8
Same name and namespace in other branches
- 8.2 src/Controller/ExifSettingsController.php \Drupal\exif\Controller\ExifSettingsController::addFields()
Add a field to a entity type.
Parameters
string $entity_type: The entity type name to be modified.
\Drupal\Core\Entity\EntityInterface $type_definition: The definition of type.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Core\Entity\EntityStorageException
2 calls to ExifSettingsController::addFields()
- ExifSettingsController::createPhotographyMediaType in src/
Controller/ ExifSettingsController.php - Create a Photography node type with default exif field.
- ExifSettingsController::createPhotographyNodeType in src/
Controller/ ExifSettingsController.php - Create an Photography node type with default exif fields.
File
- src/
Controller/ ExifSettingsController.php, line 285
Class
- ExifSettingsController
- Class ExifSettingsController manage action of settings pages.
Namespace
Drupal\exif\ControllerCode
protected function addFields($entity_type, EntityInterface $type_definition) {
// First, add image field.
$this
->addFieldToEntityType($entity_type, $type_definition, 'Photo', 'image', 'image', 'exif_readonly');
$widget_settings = [
'image_field' => 'field_image',
'exif_field' => 'naming_convention',
];
// Then add all extra fields (metadata)
// Date type.
$this
->addFieldToEntityType($entity_type, $type_definition, 'Creation date', 'exif_datetime', 'datetime', 'exif_readonly', $widget_settings);
// Text type.
$this
->addFieldToEntityType($entity_type, $type_definition, 'Photo Comment', 'exif_comments', 'text', 'exif_readonly', $widget_settings);
$this
->addFieldToEntityType($entity_type, $type_definition, 'Photo Description', 'exif_imagedescription', 'text', 'exif_readonly', $widget_settings);
$this
->addFieldToEntityType($entity_type, $type_definition, 'Photo Title', 'exif_title', 'text', 'exif_readonly', $widget_settings);
$this
->addFieldToEntityType($entity_type, $type_definition, 'Make', 'exif_make', 'text', 'exif_readonly', $widget_settings);
$this
->addFieldToEntityType($entity_type, $type_definition, 'Aperture', 'exif_aperturefnumber', 'text', 'exif_readonly', $widget_settings);
$this
->addFieldToEntityType($entity_type, $type_definition, 'Exposure', 'exif_exposuretime', 'text', 'exif_readonly', $widget_settings);
$this
->addFieldToEntityType($entity_type, $type_definition, 'ISO', 'exif_isospeedratings', 'text', 'exif_readonly', $widget_settings);
$this
->addFieldToEntityType($entity_type, $type_definition, 'Focal', 'exif_focallength', 'text', 'exif_readonly', $widget_settings);
$this
->addFieldToEntityType($entity_type, $type_definition, 'Flash', 'exif_flash', 'text', 'exif_readonly', $widget_settings);
$this
->addFieldToEntityType($entity_type, $type_definition, 'Exposure Program', 'exif_exposureprogram', 'text', 'exif_readonly', $widget_settings);
$this
->addFieldToEntityType($entity_type, $type_definition, 'Exposure Mode', 'exif_exposuremode', 'text', 'exif_readonly', $widget_settings);
$this
->addFieldToEntityType($entity_type, $type_definition, 'White Balance Mode', 'exif_whitebalance', 'text', 'exif_readonly', $widget_settings);
$this
->addFieldToEntityType($entity_type, $type_definition, 'scene Mode', 'exif_scenecapturetype', 'text', 'exif_readonly', $widget_settings);
$this
->addFieldToEntityType($entity_type, $type_definition, 'orientation', 'exif_orientation', 'text', 'exif_readonly', $widget_settings);
// Terms Type (taxonomy).
$this
->addReferenceToEntityType($entity_type, $type_definition, 'Photographer', 'exif_author', 'taxonomy_term', 'photographs_metadata', 'exif_readonly', $widget_settings);
$this
->addReferenceToEntityType($entity_type, $type_definition, 'Camera', 'exif_model', 'taxonomy_term', 'photographs_metadata', 'exif_readonly', $widget_settings);
$this
->addReferenceToEntityType($entity_type, $type_definition, 'ISO', 'exif_isospeedratings', 'taxonomy_term', 'photographs_metadata', 'exif_readonly', $widget_settings);
$widget_settings_for_tags = [
'image_field' => 'field_image',
'exif_field' => 'naming_convention',
'exif_field_separator' => ';',
];
$this
->addReferenceToEntityType($entity_type, $type_definition, 'Tags', 'exif_keywords', 'taxonomy_term', 'photographs_metadata', 'exif_readonly', $widget_settings_for_tags);
}