Skip to content
Snippets Groups Projects
Commit 85844cd5 authored by Igor Biki's avatar Igor Biki
Browse files

Merge branch 'feature/ISTWCMS-4523-ebremner-caching-information-for' into '8.x-1.x'

ISTWCMS-4523: adding cache busting for information for menu when new menu link is added

See merge request !25
parents 7d3122fe fab4e440
No related branches found
No related tags found
1 merge request!25ISTWCMS-4523: adding cache busting for information for menu when new menu link is added
...@@ -5,10 +5,31 @@ ...@@ -5,10 +5,31 @@
* Module file. * Module file.
*/ */
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\WebformInterface; use Drupal\webform\WebformInterface;
use Drupal\webform\WebformSubmissionStorageInterface; use Drupal\webform\WebformSubmissionStorageInterface;
/**
* Implements hook_entity_presave().
*/
function uw_cfg_common_entity_presave(EntityInterface $entity) {
// Check if we are on a menu link.
if ($entity->getEntityTypeId() == 'menu_link_content') {
// Check that we are on a Information For (audience) link.
if ($entity->menu_name->value == 'uw-menu-audience-menu') {
// Invalid all the menu caching.
\Drupal::cache('menu')->invalidateAll();
// Rebuild all the menus.
\Drupal::service('plugin.manager.menu.link')->rebuild();
}
}
}
/** /**
* Implements hook_form_FORM_ID_alter(). * Implements hook_form_FORM_ID_alter().
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment