function tooltip_taxonomy_taxonomy_term_presave in Tooltip Taxonomy 8
Implements hook_ENTITY_TYPE_presave().
Once a taxonomy term is being, we need to invalidate all node pages to apply the changes to tooltip.
File
- ./
tooltip_taxonomy.module, line 75 - Tooltip Taxonomy module help and theme functions.
Code
function tooltip_taxonomy_taxonomy_term_presave(EntityInterface $entity) {
// Tooltip manager service.
$tooltip_manager = \Drupal::service('tooltip_taxonomy.tooltip_manager');
// Only if the vocabulary is used for a tooltip.
$con_ids = $tooltip_manager
->hasTooltip($entity
->bundle());
if (!empty($con_ids)) {
foreach ($con_ids as $id) {
// Invalidate node pages in which
// the vocabulary is used for tooltip.
\Drupal::service('cache_tags.invalidator')
->invalidateTags([
'tooltip_taxonomy:' . $id,
]);
}
}
}