Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023

This commit is contained in:
Pantheon Automation 2015-09-04 13:20:09 -07:00 committed by Greg Anderson
parent 2720a9ec4b
commit f3791f1da3
1898 changed files with 54300 additions and 11481 deletions

View file

@ -8,7 +8,12 @@
"use strict";
/**
* Adds summaries to the book outline form.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches summary behavior to book outline forms.
*/
Drupal.behaviors.bookDetailsSummaries = {
attach: function (context) {

View file

@ -7,7 +7,6 @@
use Drupal\book\BookManager;
use Drupal\book\BookManagerInterface;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
@ -384,7 +383,7 @@ function template_preprocess_book_navigation(&$variables) {
// Provide extra variables for themers. Not needed by default.
$variables['book_id'] = $book_link['bid'];
$variables['book_title'] = SafeMarkup::checkPlain($book_link['link_title']);
$variables['book_title'] = $book_link['link_title'];
$variables['book_url'] = \Drupal::url('entity.node.canonical', array('node' => $book_link['bid']));
$variables['current_depth'] = $book_link['depth'];
$variables['tree'] = '';
@ -404,7 +403,7 @@ function template_preprocess_book_navigation(&$variables) {
'href' => $prev_href,
);
$variables['prev_url'] = $prev_href;
$variables['prev_title'] = SafeMarkup::checkPlain($prev['title']);
$variables['prev_title'] = $prev['title'];
}
/** @var \Drupal\book\BookManagerInterface $book_manager */
@ -416,7 +415,7 @@ function template_preprocess_book_navigation(&$variables) {
'href' => $parent_href,
);
$variables['parent_url'] = $parent_href;
$variables['parent_title'] = SafeMarkup::checkPlain($parent['title']);
$variables['parent_title'] = $parent['title'];
}
if ($next = $book_outline->nextLink($book_link)) {
@ -426,7 +425,7 @@ function template_preprocess_book_navigation(&$variables) {
'href' => $next_href,
);
$variables['next_url'] = $next_href;
$variables['next_title'] = SafeMarkup::checkPlain($next['title']);
$variables['next_title'] = $next['title'];
}
}
@ -464,7 +463,6 @@ function template_preprocess_book_export_html(&$variables) {
global $base_url;
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
$variables['title'] = SafeMarkup::checkPlain($variables['title']);
$variables['base_url'] = $base_url;
$variables['language'] = $language_interface;
$variables['language_rtl'] = ($language_interface->getDirection() == LanguageInterface::DIRECTION_RTL);
@ -490,7 +488,7 @@ function template_preprocess_book_export_html(&$variables) {
*/
function template_preprocess_book_node_export_html(&$variables) {
$variables['depth'] = $variables['node']->book['depth'];
$variables['title'] = SafeMarkup::checkPlain($variables['node']->label());
$variables['title'] = $variables['node']->label();
}
/**

View file

@ -26,6 +26,8 @@ services:
cache_context.route.book_navigation:
class: Drupal\book\Cache\BookNavigationCacheContext
arguments: ['@request_stack']
calls:
- [setContainer, ['@service_container']]
tags:
- { name: cache.context}

View file

@ -20,4 +20,4 @@ destination:
plugin: book
migration_dependencies:
required:
- d6_node
- d6_node:*

View file

@ -8,6 +8,7 @@
namespace Drupal\book;
use Drupal\Core\Access\AccessManagerInterface;
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Link;
@ -72,6 +73,8 @@ class BookBreadcrumbBuilder implements BreadcrumbBuilderInterface {
*/
public function build(RouteMatchInterface $route_match) {
$book_nids = array();
$breadcrumb = new Breadcrumb();
$links = array(Link::createFromRoute($this->t('Home'), '<front>'));
$book = $route_match->getParameter('node')->book;
$depth = 1;
@ -92,7 +95,9 @@ class BookBreadcrumbBuilder implements BreadcrumbBuilderInterface {
$depth++;
}
}
return $links;
$breadcrumb->setLinks($links);
$breadcrumb->setCacheContexts(['route.book_navigation']);
return $breadcrumb;
}
}

View file

@ -24,7 +24,7 @@ class BookTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('book', 'block', 'node_access_test');
public static $modules = array('book', 'block', 'node_access_test', 'book_test');
/**
* A book node.
@ -109,6 +109,45 @@ class BookTest extends WebTestBase {
return $nodes;
}
/**
* Tests the book navigation cache context.
*
* @see \Drupal\book\Cache\BookNavigationCacheContext
*/
public function testBookNavigationCacheContext() {
// Create a page node.
$this->drupalCreateContentType(['type' => 'page']);
$page = $this->drupalCreateNode();
// Create a book, consisting of book nodes.
$book_nodes = $this->createBook();
// Enable the debug output.
\Drupal::state()->set('book_test.debug_book_navigation_cache_context', TRUE);
$this->drupalLogin($this->bookAuthor);
// On non-node route.
$this->drupalGet('');
$this->assertRaw('[route.book_navigation]=book.none');
// On non-book node route.
$this->drupalGet($page->urlInfo());
$this->assertRaw('[route.book_navigation]=book.none');
// On book node route.
$this->drupalGet($book_nodes[0]->urlInfo());
$this->assertRaw('[route.book_navigation]=0|2|3');
$this->drupalGet($book_nodes[1]->urlInfo());
$this->assertRaw('[route.book_navigation]=0|2|3|4');
$this->drupalGet($book_nodes[2]->urlInfo());
$this->assertRaw('[route.book_navigation]=0|2|3|5');
$this->drupalGet($book_nodes[3]->urlInfo());
$this->assertRaw('[route.book_navigation]=0|2|6');
$this->drupalGet($book_nodes[4]->urlInfo());
$this->assertRaw('[route.book_navigation]=0|2|7');
}
/**
* Tests saving the book outline on an empty book.
*/
@ -303,7 +342,7 @@ class BookTest extends WebTestBase {
static $number = 0; // Used to ensure that when sorted nodes stay in same order.
$edit = array();
$edit['title[0][value]'] = $number . ' - SimpleTest test node ' . $this->randomMachineName(10);
$edit['title[0][value]'] = str_pad($number, 2, '0', STR_PAD_LEFT) . ' - SimpleTest test node ' . $this->randomMachineName(10);
$edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32);
$edit['book[bid]'] = $book_nid;

View file

@ -57,7 +57,7 @@ class BookUninstallTest extends KernelTestBase {
$allowed_types[] = $content_type->id();
$book_config->set('allowed_types', $allowed_types)->save();
$node = Node::create(array('type' => $content_type->id()));
$node = Node::create(array('title' => $this->randomString(), 'type' => $content_type->id()));
$node->book['bid'] = 'new';
$node->save();
@ -65,7 +65,7 @@ class BookUninstallTest extends KernelTestBase {
$validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']);
$this->assertEqual(['To uninstall Book, delete all content that is part of a book'], $validation_reasons['book']);
$book_node = Node::create(array('type' => 'book'));
$book_node = Node::create(array('title' => $this->randomString(), 'type' => 'book'));
$book_node->book['bid'] = FALSE;
$book_node->save();
@ -84,7 +84,7 @@ class BookUninstallTest extends KernelTestBase {
$module_data = _system_rebuild_module_data();
$this->assertFalse(isset($module_data['book']->info['required']), 'The book module is not required.');
$node = Node::create(array('type' => $content_type->id()));
$node = Node::create(array('title' => $this->randomString(), 'type' => $content_type->id()));
$node->save();
// One node exists but is not part of a book therefore the book module is
// not required.

View file

@ -13,7 +13,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade variables to book.settings.yml.
*
* @group book
* @group migrate_drupal_6
*/
class MigrateBookConfigsTest extends MigrateDrupal6TestBase {
@ -31,7 +31,6 @@ class MigrateBookConfigsTest extends MigrateDrupal6TestBase {
*/
protected function setUp() {
parent::setUp();
$this->loadDumps(['Variable.php']);
$this->executeMigration('d6_book_settings');
}

View file

@ -13,7 +13,7 @@ use Drupal\node\Entity\Node;
/**
* Upgrade book structure.
*
* @group book
* @group migrate_drupal_6
*/
class MigrateBookTest extends MigrateDrupal6TestBase {
@ -29,7 +29,15 @@ class MigrateBookTest extends MigrateDrupal6TestBase {
$this->installSchema('book', array('book'));
$this->installSchema('node', array('node_access'));
$id_mappings = array();
// Create a default bogus mapping for all variants of d6_node.
$id_mappings = array(
'd6_node:*' => array(
array(
array(0),
array(0),
),
),
);
for ($i = 4; $i <= 8; $i++) {
$entity = entity_create('node', array(
'type' => 'story',
@ -39,11 +47,9 @@ class MigrateBookTest extends MigrateDrupal6TestBase {
));
$entity->enforceIsNew();
$entity->save();
$id_mappings['d6_node'][] = array(array($i), array($i));
$id_mappings['d6_node__story'][] = array(array($i), array($i));
}
$this->prepareMigrations($id_mappings);
// Load database dumps to provide source data.
$this->loadDumps(['Book.php', 'MenuLinks.php']);
$this->executeMigration('d6_book');
}

View file

@ -0,0 +1,6 @@
name: 'Book module tests'
type: module
description: 'Support module for book module testing.'
package: Testing
version: VERSION
core: 8.x

View file

@ -0,0 +1,21 @@
<?php
/**
* @file
* Test module for testing the book module.
*
* This module's functionality depends on the following state variables:
* - book_test.debug_book_navigation_cache_context: Used in NodeQueryAlterTest to enable the
* node_access_all grant realm.
*
* @see \Drupal\book\Tests\BookTest::testBookNavigationCacheContext()
*/
/**
* Implements hook_page_attachments().
*/
function book_test_page_attachments(array &$page) {
if (\Drupal::state()->get('book_test.debug_book_navigation_cache_context', FALSE)) {
drupal_set_message(\Drupal::service('cache_contexts_manager')->convertTokensToKeys(['route.book_navigation'])->getKeys()[0]);
}
}