exif.module in Exif 8
Same filename and directory in other branches
Entry point for exif module.
File
exif.moduleView source
<?php
/**
* @file
* Entry point for exif module.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\exif\ExifContent;
use Drupal\exif\ExifHelp;
use Drupal\media\MediaInterface;
use Drupal\Node\NodeInterface;
/**
* Implements hook_help().
*
* Manage the exif help page route.
*/
function exif_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.exif':
return ExifHelp::content();
default:
return NULL;
}
}
/**
* Implements hook_theme().
*/
function exif_theme() {
return [
'exif_sample' => [
'variables' => [
'taxonomy' => 'http://drupal.org/handbook/modules/taxonomy/',
'image_path' => NULL,
'metadata' => NULL,
],
'template' => 'exif_sample',
],
'exif_helper_page' => [
'variables' => [
'message' => NULL,
'taxonomy' => 'http://drupal.org/handbook/modules/taxonomy/',
],
'template' => 'exif_helper_page',
],
];
}
/**
* Implements hook_entity_presave().
*
* Calculate the value for each metadata field so they can be stored correctly.
*/
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);
}
}
}
/**
* Implements hook_entity_create().
*/
function exif_entity_create(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
->checkTitle($entityType, $entity);
}
}
}
Functions
Name | Description |
---|---|
exif_entity_create | Implements hook_entity_create(). |
exif_entity_presave | Implements hook_entity_presave(). |
exif_help | Implements hook_help(). |
exif_theme | Implements hook_theme(). |