entity_usage.module in Entity Usage 8
Same filename and directory in other branches
Contains entity_usage.module.
File
entity_usage.moduleView source
<?php
/**
* @file
* Contains entity_usage.module.
*/
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\EntityInterface;
/**
* Implements hook_help().
*/
function entity_usage_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the entity_usage module.
case 'help.page.entity_usage':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Track usage of entities referenced by other entities.') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_entity_insert().
*/
function entity_usage_entity_insert(EntityInterface $entity) {
// Only act on content entities.
if (!$entity instanceof ContentEntityInterface) {
return;
}
\Drupal::service('entity_usage.entity_update_manager')
->trackUpdateOnCreation($entity);
}
/**
* Implements hook_entity_update().
*/
function entity_usage_entity_update(EntityInterface $entity) {
// Only act on content entities.
if (!$entity instanceof ContentEntityInterface) {
return;
}
\Drupal::service('entity_usage.entity_update_manager')
->trackUpdateOnEdition($entity);
}
/**
* Implements hook_entity_predelete().
*/
function entity_usage_entity_predelete(EntityInterface $entity) {
// Only act on content entities.
if (!$entity instanceof ContentEntityInterface) {
return;
}
return \Drupal::service('entity_usage.entity_update_manager')
->trackUpdateOnDeletion($entity);
}
/**
* Implements hook_entity_translation_delete().
*/
function entity_usage_entity_translation_delete(EntityInterface $translation) {
// Only act on content entities.
if (!$translation instanceof ContentEntityInterface) {
return;
}
\Drupal::service('entity_usage.entity_update_manager')
->trackUpdateOnDeletion($translation);
}
Functions
Name | Description |
---|---|
entity_usage_entity_insert | Implements hook_entity_insert(). |
entity_usage_entity_predelete | Implements hook_entity_predelete(). |
entity_usage_entity_translation_delete | Implements hook_entity_translation_delete(). |
entity_usage_entity_update | Implements hook_entity_update(). |
entity_usage_help | Implements hook_help(). |