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__);
  }
}
doc_Drupal
2016-10-29 09:27:28
Comments
Leave a Comment

Please login to continue.