function BookManager::bookLinkTranslate
Same name in this branch
- 11.x core/modules/book/src/ProxyClass/BookManager.php \Drupal\book\ProxyClass\BookManager::bookLinkTranslate()
Same name in other branches
- 9 core/modules/book/src/BookManager.php \Drupal\book\BookManager::bookLinkTranslate()
- 8.9.x core/modules/book/src/BookManager.php \Drupal\book\BookManager::bookLinkTranslate()
- 10 core/modules/book/src/ProxyClass/BookManager.php \Drupal\book\ProxyClass\BookManager::bookLinkTranslate()
- 10 core/modules/book/src/BookManager.php \Drupal\book\BookManager::bookLinkTranslate()
2 calls to BookManager::bookLinkTranslate()
- BookManager::doBookTreeCheckAccess in core/
modules/ book/ src/ BookManager.php - Sorts the menu tree and recursively checks access for each item.
- BookManager::loadBookLinks in core/
modules/ book/ src/ BookManager.php
File
-
core/
modules/ book/ src/ BookManager.php, line 1049
Class
- BookManager
- Defines a book manager.
Namespace
Drupal\bookCode
public function bookLinkTranslate(&$link) {
// Check access via the api, since the query node_access tag doesn't check
// for unpublished nodes.
// @todo load the nodes en-mass rather than individually.
// @see https://www.drupal.org/project/drupal/issues/2470896
$node = $this->entityTypeManager
->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']) {
// The node label will be the value for the current language.
$node = $this->entityRepository
->getTranslationFromContext($node);
$link['title'] = $node->label();
$link['options'] = [];
}
return $link;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.