diff --git a/core/modules/book/lib/Drupal/book/BookManager.php b/core/modules/book/lib/Drupal/book/BookManager.php index 6840a08..5b89ea3 100644 --- a/core/modules/book/lib/Drupal/book/BookManager.php +++ b/core/modules/book/lib/Drupal/book/BookManager.php @@ -24,7 +24,7 @@ class BookManager { * * @var \Drupal\Core\Database\Connection */ - protected $database; + protected $connection; /** * Entity manager Service Object. @@ -50,8 +50,8 @@ class BookManager { /** * Constructs a BookManager object. */ - public function __construct(Connection $database, EntityManager $entityManager, TranslationInterface $translation) { - $this->database = $database; + public function __construct(Connection $connection, EntityManager $entityManager, TranslationInterface $translation) { + $this->connection = $connection; $this->entityManager = $entityManager; $this->translation = $translation; } @@ -77,10 +77,10 @@ public function getAllBooks() { */ protected function loadBooks() { $this->books = array(); - $nids = $this->database->query("SELECT DISTINCT(bid) FROM {book}")->fetchCol(); + $nids = $this->connection->query("SELECT DISTINCT(bid) FROM {book}")->fetchCol(); if ($nids) { - $query = $this->database->select('book', 'b', array('fetch' => \PDO::FETCH_ASSOC)); + $query = $this->connection->select('book', 'b', array('fetch' => \PDO::FETCH_ASSOC)); $query->join('menu_links', 'ml', 'b.mlid = ml.mlid'); $query->fields('b'); $query->fields('ml'); @@ -284,12 +284,12 @@ public function updateOutline(NodeInterface $node) { else { // Check in case the parent is not is this book; the book takes precedence. if (!empty($node->book['plid'])) { - $parent = $database->query("SELECT * FROM {book} WHERE mlid = :mlid", array( + $parent = $this->connection->query("SELECT * FROM {book} WHERE mlid = :mlid", array( ':mlid' => $node->book['plid'], ))->fetchAssoc(); } if (empty($node->book['plid']) || !$parent || $parent['bid'] != $node->book['bid']) { - $node->book['plid'] = $database->query("SELECT mlid FROM {book} WHERE nid = :nid", array( + $node->book['plid'] = $this->connection->query("SELECT mlid FROM {book} WHERE nid = :nid", array( ':nid' => $node->book['bid'], ))->fetchField(); $node->book['parent_mismatch'] = TRUE; // Likely when JS is disabled. @@ -301,7 +301,7 @@ public function updateOutline(NodeInterface $node) { if ($node->book->save()) { if ($new) { // Insert new. - $database->insert('book') + $this->connection->insert('book') ->fields(array( 'nid' => $node->id(), 'mlid' => $node->book['mlid'], @@ -312,7 +312,7 @@ public function updateOutline(NodeInterface $node) { drupal_static_reset('book_get_books'); } else { - if ($node->book['bid'] != $database->query("SELECT bid FROM {book} WHERE nid = :nid", array( + if ($node->book['bid'] != $this->connection->query("SELECT bid FROM {book} WHERE nid = :nid", array( ':nid' => $node->id(), ))->fetchField()) { // Update the bid for this page and all children. @@ -372,7 +372,7 @@ public function createMenuName($id) { * A fully loaded menu link that is part of the book hierarchy. */ function updateID($book_link) { - $query = $database->select('menu_links'); + $query = $this->connection->select('menu_links'); $query->addField('menu_links', 'mlid'); for ($i = 1; $i <= MENU_MAX_DEPTH && $book_link["p$i"]; $i++) { $query->condition("p$i", $book_link["p$i"]); @@ -380,7 +380,7 @@ function updateID($book_link) { $mlids = $query->execute()->fetchCol(); if ($mlids) { - $database->update('book') + $this->connection->update('book') ->fields(array('bid' => $book_link['bid'])) ->condition('mlid', $mlids, 'IN') ->execute();