Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By dawehner on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
In Drupal 7, indicating that the menu route needed to rebuilt was done via a variable:
variable_set('menu_rebuild_needed', TRUE);
Earlier in D8, the variable was moved to state:
\Drupal::state()->set('menu_rebuild_needed', TRUE);
Now this is done on the route builder:
\Drupal::service('router.builder')->setRebuildNeeded();
In earlier version of Drupal 8 route rebuilding was done explicit
\Drupal::service('router.builder')->rebuild();
as this costs a lot of computing power you can now mark the router to be rebuilt later (which will be done at the end of the request with the Kernel terminate event):
\Drupal::service('router.builder')->setRebuildNeeded();
Additional the RouteBuilder got an interface:
Drupal\Core\Routing\RouteBuilderInterface
Impacts:
Module developers