Loads Books Array.
protected function loadBooks() {
$this->books = array();
$nids = $this->database
->query("SELECT DISTINCT(bid) FROM {book}")
->fetchCol();
if ($nids) {
$query = $this->database
->select('book', 'b', array(
'fetch' => \PDO::FETCH_ASSOC,
));
$query
->join('menu_links', 'ml', 'b.mlid = ml.mlid');
$query
->fields('b');
$query
->fields('ml');
$query
->condition('b.nid', $nids);
$query
->orderBy('ml.weight');
$query
->orderBy('ml.link_title');
$query
->addTag('node_access');
$query
->addMetaData('base_table', 'book');
$book_links = $query
->execute();
$nodes = $this->entityManager
->getStorageController('node')
->load($nids);
foreach ($book_links as $link) {
$nid = $link['nid'];
if (isset($nodes[$nid]) && $nodes[$nid]->status) {
$link['href'] = $link['link_path'];
$link['options'] = unserialize($link['options']);
$link['title'] = $nodes[$nid]
->label();
$link['type'] = $nodes[$nid]
->bundle();
$this->books[$link['bid']] = $link;
}
}
}
}