5

I am developing a custom module. In this module, I want to delete menu caches programmatically. For this, I have used

\Drupal::cache('menu')->invalidateAll(); // for clearing the menu cache      
\Drupal::service('plugin.manager.menu.link')->rebuild(); // rebuild the menu

But somehow, menu cache seems not being cleared and still the old menu is being displayed. How can I force Drupal to have my updated menu being displayed?

0
7

Menu's are displayed via blocks. You will probably have to clear the block render cache as well.

\Drupal::cache('block')->invalidateAll();
1
  • Getting error message = You have requested a non-existent service "cache.block". I'm not certain what would be correct. I see "block" and "menu link" items in the cache_entity table, so that might be the correct path to take. – beltouche Oct 15 '20 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.