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;
} /**
* Sorts and returns the built data representing a book tree.
*
* @param array $links
* A flat array of book links that are part of the book. Each array element
* is an associative array of information about the book link, containing
* the fields from the {book} table. This array must be ordered depth-first.
* @param array $parents
* An array of the node ID values that are in the path from the current
* page to the root of the book tree.
* @param int $depth
* The minimum depth to include in the returned book tree.
*
* @return array
* An array of book links in the form of a tree. Each item in the tree is an
* associative array containing:
* - link: The book link item from $links, with additional element
* 'in_active_trail' (TRUE if the link ID was in $parents).
* - below: An array containing the sub-tree of this item, where each
* element is a tree item array with 'link' and 'below' elements. This
* array will be empty if the book link has no items in its sub-tree
* having a depth greater than or equal to $depth.
*/