BookManager::bookLinkTranslate

public BookManager::bookLinkTranslate(&$link)

Provides book loading, access control and translation.

Note: copied from _menu_link_translate() in menu.inc, but reduced to the minimal code that's used.

Parameters

array $link: A book link.

Overrides BookManagerInterface::bookLinkTranslate

File

core/modules/book/src/BookManager.php, line 980

Class

BookManager
Defines a book manager.

Namespace

Drupal\book

Code

public function bookLinkTranslate(&$link) {
  $node = NULL;
  // Access will already be set in the tree functions.
  if (!isset($link['access'])) {
    $node = $this->entityManager->getStorage('node')->load($link['nid']);
    $link['access'] = $node && $node->access('view');
  }
  // For performance, don't localize a link the user can't access.
  if ($link['access']) {
    // @todo - load the nodes en-mass rather than individually.
    if (!$node) {
      $node = $this->entityManager->getStorage('node')
        ->load($link['nid']);
    }
    // The node label will be the value for the current user's language.
    $link['title'] = $node->label();
    $link['options'] = array();
  }
  return $link;
}
doc_Drupal
2016-10-29 08:48:08
Comments
Leave a Comment

Please login to continue.