getBookParents example

// Used for both book manager cache services: backend chain and memory.     $cache = $this->createMock(CacheBackendInterface::class);
    $this->bookManager = new BookManager($this->entityTypeManager, $this->translation, $this->configFactory, $this->bookOutlineStorage, $this->renderer, $this->languageManager, $this->entityRepository, $cache$cache);
  }

  /** * Tests the getBookParents() method. * * @dataProvider providerTestGetBookParents */
  public function testGetBookParents($book$parent$expected) {
    $this->assertEquals($expected$this->bookManager->getBookParents($book$parent));
  }

  /** * Provides test data for testGetBookParents. * * @return array * The test data. */
  public function providerTestGetBookParents() {
    $empty = [
      'p1' => 0,
      


  /** * {@inheritdoc} */
  public function saveBookLink(array $link$new) {
    // Keep track of Book IDs for cache clear.     $affected_bids[$link['bid']] = $link['bid'];
    $link += $this->getLinkDefaults($link['nid']);
    if ($new) {
      // Insert new.       $parents = $this->getBookParents($link(array) $this->loadBookLink($link['pid'], FALSE));
      $this->bookOutlineStorage->insert($link$parents);

      // Update the has_children status of the parent.       $this->updateParent($link);
    }
    else {
      $original = $this->loadBookLink($link['nid'], FALSE);
      // Using the Book ID as the key keeps this unique.       $affected_bids[$original['bid']] = $original['bid'];
      // Handle links that are moving.       if ($link['bid'] != $original['bid'] || $link['pid'] != $original['pid']) {
        
Home | Imprint | This part of the site doesn't use cookies.