diff --git a/core/modules/book/book.services.yml b/core/modules/book/book.services.yml index f84ead9..ce5f3cd 100644 --- a/core/modules/book/book.services.yml +++ b/core/modules/book/book.services.yml @@ -6,7 +6,7 @@ services: - { name: breadcrumb_builder, priority: 701 } book.manager: class: Drupal\book\BookManager - arguments: ['@entity.manager', '@string_translation', '@config.factory', '@book.storage'] + arguments: ['@entity.manager', '@string_translation', '@config.factory', '@book.outline_storage'] tags: - { name: backend_overridable } book.outline: @@ -15,7 +15,7 @@ services: book.export: class: Drupal\book\BookExport arguments: ['@entity.manager', '@book.manager'] - book.storage: + book.outline_storage: class: Drupal\book\BookOutlineStorage arguments: ['@database'] access_check.book.removable: diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index 42ee817..0035cd3 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -50,11 +50,11 @@ class BookManager implements BookManagerInterface { protected $books; /** - * Book Storage. + * Book outline storage. * * @var \Drupal\book\BookOutlineStorageInterface */ - protected $bookStorage; + protected $bookOutlineStorage; /** * Stores flattened book trees. @@ -66,11 +66,11 @@ class BookManager implements BookManagerInterface { /** * Constructs a BookManager object. */ - public function __construct(EntityManagerInterface $entity_manager, TranslationInterface $translation, ConfigFactoryInterface $config_factory, BookOutlineStorageInterface $book_storage) { + public function __construct(EntityManagerInterface $entity_manager, TranslationInterface $translation, ConfigFactoryInterface $config_factory, BookOutlineStorageInterface $book_outline_storage) { $this->entityManager = $entity_manager; $this->stringTranslation = $translation; $this->configFactory = $config_factory; - $this->bookStorage = $book_storage; + $this->bookOutlineStorage = $book_outline_storage; } /** @@ -88,10 +88,10 @@ public function getAllBooks() { */ protected function loadBooks() { $this->books = array(); - $nids = $this->bookStorage->getBooks(); + $nids = $this->bookOutlineStorage->getBooks(); if ($nids) { - $book_links = $this->bookStorage->loadMultiple($nids); + $book_links = $this->bookOutlineStorage->loadMultiple($nids); $nodes = $this->entityManager->getStorage('node')->loadMultiple($nids); // @todo: Sort by weight and translated title. @@ -141,7 +141,7 @@ public function getParentDepthLimit(array $book_link) { * the passed book link. */ protected function findChildrenRelativeDepth(array $book_link) { - $max_depth = $this->bookStorage->getChildRelativeDepth($book_link, static::BOOK_MAX_DEPTH); + $max_depth = $this->bookOutlineStorage->getChildRelativeDepth($book_link, static::BOOK_MAX_DEPTH); return ($max_depth > $book_link['depth']) ? $max_depth - $book_link['depth'] : 0; } @@ -415,11 +415,11 @@ public function getTableOfContents($bid, $depth_limit, array $exclude = array()) */ public function deleteFromBook($nid) { $original = $this->loadBookLink($nid, FALSE); - $this->bookStorage->delete($nid); + $this->bookOutlineStorage->delete($nid); if ($nid == $original['bid']) { // Handle deletion of a top-level post. - $result = $this->bookStorage->loadBookChildren($nid); + $result = $this->bookOutlineStorage->loadBookChildren($nid); foreach ($result as $child) { $child['bid'] = $child['nid']; @@ -608,7 +608,7 @@ protected function doBookTreeBuild($bid, array $parameters = array()) { if (!isset($trees[$tree_cid])) { $min_depth = (isset($parameters['min_depth']) ? $parameters['min_depth'] : 1); - $result = $this->bookStorage->getBookMenuTree($bid, $parameters, $min_depth, static::BOOK_MAX_DEPTH); + $result = $this->bookOutlineStorage->getBookMenuTree($bid, $parameters, $min_depth, static::BOOK_MAX_DEPTH); // Build an ordered array of links using the query result object. $links = array(); @@ -690,7 +690,7 @@ public function loadBookLink($nid, $translate = TRUE) { * {@inheritdoc} */ public function loadBookLinks($nids, $translate = TRUE) { - $result = $this->bookStorage->loadMultiple($nids); + $result = $this->bookOutlineStorage->loadMultiple($nids); $links = array(); foreach ($result as $link) { if ($translate) { @@ -712,7 +712,7 @@ public function saveBookLink(array $link, $new) { if ($new) { // Insert new. $parents = $this->getBookParents($link, (array) $this->loadBookLink($link['pid'], FALSE)); - $this->bookStorage->insert($link, $parents); + $this->bookOutlineStorage->insert($link, $parents); // Update the has_children status of the parent. $this->updateParent($link); @@ -748,7 +748,7 @@ public function saveBookLink(array $link, $new) { $this->updateParent($link); } // Update the weight and pid. - $this->bookStorage->update($link['nid'], array( + $this->bookOutlineStorage->update($link['nid'], array( 'weight' => $link['weight'], 'pid' => $link['pid'], 'bid' => $link['bid'], @@ -791,7 +791,7 @@ protected function moveChildren(array $link, array $original) { $expressions = array_reverse($expressions); } - $this->bookStorage->updateMovedChildren($link['bid'], $original, $expressions, $shift); + $this->bookOutlineStorage->updateMovedChildren($link['bid'], $original, $expressions, $shift); } /** @@ -813,7 +813,7 @@ protected function updateParent(array $link) { // Nothing to update. return TRUE; } - return $this->bookStorage->update($link['pid'], array('has_children' => 1)); + return $this->bookOutlineStorage->update($link['pid'], array('has_children' => 1)); } /** @@ -836,13 +836,13 @@ protected function updateOriginalParent(array $original) { return TRUE; } // Check if $original had at least one child. - $original_number_of_children = $this->bookStorage->countOriginalLinkChildren($original); + $original_number_of_children = $this->bookOutlineStorage->countOriginalLinkChildren($original); $parent_has_children = ((bool) $original_number_of_children) ? 1 : 0; // Update the parent. If the original link did not have children, then the // parent now does not have children. If the original had children, then the // the parent has children now (still). - return $this->bookStorage->update($original['pid'], array('has_children' => $parent_has_children)); + return $this->bookOutlineStorage->update($original['pid'], array('has_children' => $parent_has_children)); } /** @@ -1028,7 +1028,7 @@ public function bookSubtreeData($link) { // If the subtree data was not in the cache, $data will be NULL. if (!isset($data)) { - $result = $this->bookStorage->getBookSubtree($link, static::BOOK_MAX_DEPTH); + $result = $this->bookOutlineStorage->getBookSubtree($link, static::BOOK_MAX_DEPTH); $links = array(); foreach ($result as $item) { $links[] = $item; diff --git a/core/modules/book/tests/src/Unit/BookManagerTest.php b/core/modules/book/tests/src/Unit/BookManagerTest.php index e74d8ae..2c12385 100644 --- a/core/modules/book/tests/src/Unit/BookManagerTest.php +++ b/core/modules/book/tests/src/Unit/BookManagerTest.php @@ -45,11 +45,11 @@ class BookManagerTest extends UnitTestCase { protected $bookManager; /** - * Book Storage. + * Book outline storage. * * @var \Drupal\book\BookOutlineStorageInterface */ - protected $bookStorage; + protected $bookOutlineStorage; /** * {@inheritdoc} @@ -58,8 +58,8 @@ protected function setUp() { $this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $this->translation = $this->getStringTranslationStub(); $this->configFactory = $this->getConfigFactoryStub(array()); - $this->bookStorage = $this->getMock('Drupal\book\BookOutlineStorageInterface'); - $this->bookManager = new BookManager($this->entityManager, $this->translation, $this->configFactory, $this->bookStorage); + $this->bookOutlineStorage = $this->getMock('Drupal\book\BookOutlineStorageInterface'); + $this->bookManager = new BookManager($this->entityManager, $this->translation, $this->configFactory, $this->bookOutlineStorage); } /**