protected function MenuRouterRebuildSubscriber::menuLinksRebuild

protected MenuRouterRebuildSubscriber::menuLinksRebuild()

Perform menu-specific rebuilding.

File

core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php, line 56

Class

MenuRouterRebuildSubscriber
Rebuilds the default menu links and runs menu-specific code if necessary.

Namespace

Drupal\Core\EventSubscriber

Code

protected function menuLinksRebuild() {
  if ($this->lock->acquire(__FUNCTION__)) {
    $transaction = db_transaction();
    try {
      // Ensure the menu links are up to date.
      $this->menuLinkManager->rebuild();
      // Ignore any database replicas temporarily.
      db_ignore_replica();
    }
    catch (\Exception $e) {
      $transaction->rollback();
      watchdog_exception('menu', $e);
    }

    $this->lock->release(__FUNCTION__);
  }
  else {
    // Wait for another request that is already doing this work.
    // We choose to block here since otherwise the router item may not
    // be available during routing resulting in a 404.
    $this->lock->wait(__FUNCTION__);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!EventSubscriber!MenuRouterRebuildSubscriber.php/function/MenuRouterRebuildSubscriber::menuLinksRebuild/8.1.x