BookManager::loadBooks

protected BookManager::loadBooks()

Loads Books Array.

File

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

Class

BookManager
Defines a book manager.

Namespace

Drupal\book

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
protected function loadBooks() {
  $this->books = array();
  $nids = $this->bookOutlineStorage->getBooks();
 
  if ($nids) {
    $book_links = $this->bookOutlineStorage->loadMultiple($nids);
    $nodes = $this->entityManager->getStorage('node')->loadMultiple($nids);
    // @todo: Sort by weight and translated title.
 
    // @todo: use route name for links, not system path.
    foreach ($book_links as $link) {
      $nid = $link['nid'];
      if (isset($nodes[$nid]) && $nodes[$nid]->status) {
        $link['url'] = $nodes[$nid]->urlInfo();
        $link['title'] = $nodes[$nid]->label();
        $link['type'] = $nodes[$nid]->bundle();
        $this->books[$link['bid']] = $link;
      }
    }
  }
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.