$nodes =
$this->entityTypeManager->
getStorage('node'
)->
loadMultiple($nids);
$nodes =
array_map([$this->entityRepository, 'getTranslationFromContext'
],
$nodes);
foreach ($tree as $data) { $nid =
$data['link'
]['nid'
];
// Check for excluded or missing node.
if (empty($nodes[$nid])) { continue;
} $toc[$nid] =
$indent . ' ' . Unicode::
truncate($nodes[$nid]->
label(), 30, TRUE, TRUE
);
if ($data['below'
]) { $this->
recurseTableOfContents($data['below'
],
$indent . '--',
$toc,
$exclude,
$depth_limit);
} } } /**
* {@inheritdoc}
*/
public function getTableOfContents($bid,
$depth_limit, array
$exclude =
[]) { $tree =
$this->
bookTreeAllData($bid);
$toc =
[];
$this->
recurseTableOfContents($tree, '',
$toc,
$exclude,
$depth_limit);