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

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
2016-10-29 08:48:12
Comments
Leave a Comment

Please login to continue.