updated core to 8.6.1 via composer

This commit is contained in:
2018-09-12 13:58:26 +02:00
parent a9a219f2ed
commit ea56b9fba3
4443 changed files with 112098 additions and 40708 deletions
+15 -13
View File
@@ -3,7 +3,7 @@
* Javascript behaviors for the Book module.
*/
(function ($, Drupal) {
(function($, Drupal) {
/**
* Adds summaries to the book outline form.
*
@@ -14,19 +14,21 @@
*/
Drupal.behaviors.bookDetailsSummaries = {
attach(context) {
$(context).find('.book-outline-form').drupalSetSummary((context) => {
const $select = $(context).find('.book-title-select');
const val = $select.val();
$(context)
.find('.book-outline-form')
.drupalSetSummary(context => {
const $select = $(context).find('.book-title-select');
const val = $select.val();
if (val === '0') {
return Drupal.t('Not in book');
}
else if (val === 'new') {
return Drupal.t('New book');
}
if (val === '0') {
return Drupal.t('Not in book');
}
if (val === 'new') {
return Drupal.t('New book');
}
return Drupal.checkPlain($select.find(':selected').text());
});
return Drupal.checkPlain($select.find(':selected').text());
});
},
};
}(jQuery, Drupal));
})(jQuery, Drupal);
+1 -1
View File
@@ -5,5 +5,5 @@ package: Core
version: VERSION
core: 8.x
dependencies:
- node
- drupal:node
configure: book.settings
+2 -1
View File
@@ -14,7 +14,8 @@
if (val === '0') {
return Drupal.t('Not in book');
} else if (val === 'new') {
}
if (val === 'new') {
return Drupal.t('New book');
}
-1
View File
@@ -6,4 +6,3 @@ drupal.book:
- core/jquery
- core/drupal
- core/drupal.form
+14 -1
View File
@@ -111,7 +111,7 @@ function book_node_links_alter(array &$links, NodeInterface $node, array &$conte
'type' => 'html',
'node' => $node->id(),
]),
'attributes' => ['title' => t('Show a printer-friendly version of this book page and its sub-pages.')]
'attributes' => ['title' => t('Show a printer-friendly version of this book page and its sub-pages.')],
];
}
}
@@ -539,3 +539,16 @@ function book_node_type_update(NodeTypeInterface $type) {
$config->save();
}
}
/**
* Implements hook_migration_plugins_alter().
*/
function book_migration_plugins_alter(array &$migrations) {
// Book settings are migrated identically for Drupal 6 and Drupal 7. However,
// a d6_book_settings migration already existed before the consolidated
// book_settings migration existed, so to maintain backwards compatibility,
// ensure that d6_book_settings is an alias of book_settings.
if (isset($migrations['book_settings'])) {
$migrations['d6_book_settings'] = &$migrations['book_settings'];
}
}
@@ -1,7 +1,8 @@
id: d6_book_settings
id: book_settings
label: Book configuration
migration_tags:
- Drupal 6
- Drupal 7
- Configuration
source:
plugin: variable
+1 -1
View File
@@ -4,7 +4,7 @@ migration_tags:
- Drupal 6
- Content
source:
plugin: d6_book
plugin: book
process:
nid: nid
'book/bid': bid
+24
View File
@@ -0,0 +1,24 @@
id: d7_book
label: Books
migration_tags:
- Drupal 7
- Content
source:
plugin: book
process:
nid: nid
'book/bid': bid
'book/weight': weight
'book/pid':
-
plugin: skip_on_empty
method: process
source: plid
-
plugin: migration_lookup
migration: d7_book
destination:
plugin: book
migration_dependencies:
required:
- d7_node
@@ -246,7 +246,8 @@ interface BookManagerInterface {
* A data structure representing the tree as returned from buildBookOutlineData.
*
* @return array
* A structured array to be rendered by drupal_render().
* A structured array to be rendered by
* \Drupal\Core\Render\RendererInterface::render().
*
* @see \Drupal\Core\Menu\MenuLinkTree::build
*/
@@ -110,7 +110,6 @@ interface BookOutlineStorageInterface {
*/
public function insert($link, $parents);
/**
* Updates book reference for links that were moved between books.
*
@@ -154,7 +154,7 @@ class BookController extends ControllerBase {
// @todo Convert the custom export functionality to serializer.
if (!method_exists($this->bookExport, $method)) {
drupal_set_message(t('Unknown export format.'));
$this->messenger()->addStatus(t('Unknown export format.'));
throw new NotFoundHttpException();
}
@@ -127,7 +127,7 @@ class BookAdminEditForm extends FormBase {
}
}
drupal_set_message($this->t('Updated book %title.', ['%title' => $form['#node']->label()]));
$this->messenger()->addStatus($this->t('Updated book %title.', ['%title' => $form['#node']->label()]));
}
/**
+10 -10
View File
@@ -5,7 +5,7 @@ namespace Drupal\book\Form;
use Drupal\book\BookManagerInterface;
use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
@@ -35,8 +35,8 @@ class BookOutlineForm extends ContentEntityForm {
/**
* Constructs a BookOutlineForm object.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
* The entity repository.
* @param \Drupal\book\BookManagerInterface $book_manager
* The BookManager service.
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
@@ -44,8 +44,8 @@ class BookOutlineForm extends ContentEntityForm {
* @param \Drupal\Component\Datetime\TimeInterface $time
* The time service.
*/
public function __construct(EntityManagerInterface $entity_manager, BookManagerInterface $book_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
parent::__construct($entity_manager, $entity_type_bundle_info, $time);
public function __construct(EntityRepositoryInterface $entity_repository, BookManagerInterface $book_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
parent::__construct($entity_repository, $entity_type_bundle_info, $time);
$this->bookManager = $book_manager;
}
@@ -54,7 +54,7 @@ class BookOutlineForm extends ContentEntityForm {
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.manager'),
$container->get('entity.repository'),
$container->get('book.manager'),
$container->get('entity_type.bundle.info'),
$container->get('datetime.time')
@@ -113,7 +113,7 @@ class BookOutlineForm extends ContentEntityForm {
);
$book_link = $form_state->getValue('book');
if (!$book_link['bid']) {
drupal_set_message($this->t('No changes were made'));
$this->messenger()->addStatus($this->t('No changes were made'));
return;
}
@@ -121,15 +121,15 @@ class BookOutlineForm extends ContentEntityForm {
if ($this->bookManager->updateOutline($this->entity)) {
if (isset($this->entity->book['parent_mismatch']) && $this->entity->book['parent_mismatch']) {
// This will usually only happen when JS is disabled.
drupal_set_message($this->t('The post has been added to the selected book. You may now position it relative to other pages.'));
$this->messenger()->addStatus($this->t('The post has been added to the selected book. You may now position it relative to other pages.'));
$form_state->setRedirectUrl($this->entity->urlInfo('book-outline-form'));
}
else {
drupal_set_message($this->t('The book outline has been updated.'));
$this->messenger()->addStatus($this->t('The book outline has been updated.'));
}
}
else {
drupal_set_message($this->t('There was an error adding the post to the book.'), 'error');
$this->messenger()->addError($this->t('There was an error adding the post to the book.'));
}
}
@@ -103,7 +103,7 @@ class BookRemoveForm extends ConfirmFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
if ($this->bookManager->checkNodeIsRemovable($this->node)) {
$this->bookManager->deleteFromBook($this->node->id());
drupal_set_message($this->t('The post has been removed from the book.'));
$this->messenger()->addStatus($this->t('The post has been removed from the book.'));
}
$form_state->setRedirectUrl($this->getCancelUrl());
}
@@ -0,0 +1,63 @@
<?php
namespace Drupal\book\Plugin\migrate\source;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 6 and 7 book source.
*
* @MigrateSource(
* id = "book",
* source_module = "book",
* )
*/
class Book extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('book', 'b')->fields('b', ['nid', 'bid']);
$query->join('menu_links', 'ml', 'b.mlid = ml.mlid');
$ml_fields = ['mlid', 'plid', 'weight', 'has_children', 'depth'];
foreach (range(1, 9) as $i) {
$field = "p$i";
$ml_fields[] = $field;
$query->orderBy('ml.' . $field);
}
return $query->fields('ml', $ml_fields);
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['mlid']['type'] = 'integer';
$ids['mlid']['alias'] = 'ml';
return $ids;
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'nid' => $this->t('Node ID'),
'bid' => $this->t('Book ID'),
'mlid' => $this->t('Menu link ID'),
'plid' => $this->t('Parent link ID'),
'weight' => $this->t('Weight'),
'p1' => $this->t('The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the parent link mlid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.'),
'p2' => $this->t('The second mlid in the materialized path. See p1.'),
'p3' => $this->t('The third mlid in the materialized path. See p1.'),
'p4' => $this->t('The fourth mlid in the materialized path. See p1.'),
'p5' => $this->t('The fifth mlid in the materialized path. See p1.'),
'p6' => $this->t('The sixth mlid in the materialized path. See p1.'),
'p7' => $this->t('The seventh mlid in the materialized path. See p1.'),
'p8' => $this->t('The eighth mlid in the materialized path. See p1.'),
'p9' => $this->t('The ninth mlid in the materialized path. See p1.'),
];
}
}
@@ -2,7 +2,9 @@
namespace Drupal\book\Plugin\migrate\source\d6;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
use Drupal\book\Plugin\migrate\source\Book as BookGeneral;
@trigger_error('Book is deprecated in Drupal 8.6.x and will be removed before Drupal 9.0.x. Use \Drupal\book\Plugin\migrate\source\Book instead. See https://www.drupal.org/node/2947487 for more information.', E_USER_DEPRECATED);
/**
* Drupal 6 book source.
@@ -11,54 +13,9 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
* id = "d6_book",
* source_module = "book"
* )
*
* @deprecated in Drupal 8.6.x, to be removed before Drupal 9.0.x. Use
* \Drupal\book\Plugin\migrate\source\Book instead. See
* https://www.drupal.org/node/2947487 for more information.
*/
class Book extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('book', 'b')->fields('b', ['nid', 'bid']);
$query->join('menu_links', 'ml', 'b.mlid = ml.mlid');
$ml_fields = ['mlid', 'plid', 'weight', 'has_children', 'depth'];
for ($i = 1; $i <= 9; $i++) {
$field = "p$i";
$ml_fields[] = $field;
$query->orderBy('ml.' . $field);
}
$query->fields('ml', $ml_fields);
return $query;
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['mlid']['type'] = 'integer';
$ids['mlid']['alias'] = 'ml';
return $ids;
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'nid' => $this->t('Node ID'),
'bid' => $this->t('Book ID'),
'mlid' => $this->t('Menu link ID'),
'plid' => $this->t('Parent link ID'),
'weight' => $this->t('Weight'),
'p1' => $this->t('The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the parent link mlid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.'),
'p2' => $this->t('The second mlid in the materialized path. See p1.'),
'p3' => $this->t('The third mlid in the materialized path. See p1.'),
'p4' => $this->t('The fourth mlid in the materialized path. See p1.'),
'p5' => $this->t('The fifth mlid in the materialized path. See p1.'),
'p6' => $this->t('The sixth mlid in the materialized path. See p1.'),
'p7' => $this->t('The seventh mlid in the materialized path. See p1.'),
'p8' => $this->t('The eighth mlid in the materialized path. See p1.'),
'p9' => $this->t('The ninth mlid in the materialized path. See p1.'),
];
}
}
class Book extends BookGeneral {}
@@ -17,6 +17,6 @@
function book_test_page_attachments(array &$page) {
$page['#cache']['tags'][] = 'book_test.debug_book_navigation_cache_context';
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]);
\Drupal::messenger()->addStatus(\Drupal::service('cache_contexts_manager')->convertTokensToKeys(['route.book_navigation'])->getKeys()[0]);
}
}
@@ -5,5 +5,5 @@ package: Testing
version: VERSION
core: 8.x
dependencies:
- book
- views
- drupal:book
- drupal:views
@@ -3,7 +3,7 @@
namespace Drupal\Tests\book\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\workflows\Entity\Workflow;
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
/**
* Tests Book and Content Moderation integration.
@@ -13,6 +13,7 @@ use Drupal\workflows\Entity\Workflow;
class BookContentModerationTest extends BrowserTestBase {
use BookTestTrait;
use ContentModerationTestTrait;
/**
* Modules to install.
@@ -30,7 +31,7 @@ class BookContentModerationTest extends BrowserTestBase {
$this->drupalPlaceBlock('system_breadcrumb_block');
$this->drupalPlaceBlock('page_title_block');
$workflow = Workflow::load('editorial');
$workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'book');
$workflow->save();
@@ -2,7 +2,7 @@
namespace Drupal\Tests\book\Functional;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Entity\EntityInterface;
/**
@@ -104,7 +104,7 @@ trait BookTestTrait {
/** @var \Drupal\Core\Url $url */
$url = $previous->urlInfo();
$url->setOptions(['attributes' => ['rel' => ['prev'], 'title' => t('Go to previous page')]]);
$text = SafeMarkup::format('<b></b> @label', ['@label' => $previous->label()]);
$text = new FormattableMarkup('<b></b> @label', ['@label' => $previous->label()]);
$this->assertRaw(\Drupal::l($text, $url), 'Previous page link found.');
}
@@ -119,7 +119,7 @@ trait BookTestTrait {
/** @var \Drupal\Core\Url $url */
$url = $next->urlInfo();
$url->setOptions(['attributes' => ['rel' => ['next'], 'title' => t('Go to next page')]]);
$text = SafeMarkup::format('@label <b></b>', ['@label' => $next->label()]);
$text = new FormattableMarkup('@label <b></b>', ['@label' => $next->label()]);
$this->assertRaw(\Drupal::l($text, $url), 'Next page link found.');
}
@@ -4,7 +4,7 @@ namespace Drupal\Tests\book\FunctionalJavascript;
use Behat\Mink\Exception\ExpectationException;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\node\Entity\Node;
/**
@@ -12,7 +12,7 @@ use Drupal\node\Entity\Node;
*
* @group book
*/
class BookJavascriptTest extends JavascriptTestBase {
class BookJavascriptTest extends WebDriverTestBase {
/**
* {@inheritdoc}
@@ -76,7 +76,7 @@ class BookUninstallTest extends KernelTestBase {
$book_node->delete();
// No nodes exist therefore the book module is not required.
$module_data = _system_rebuild_module_data();
$module_data = \Drupal::service('extension.list.module')->reset()->getList();
$this->assertFalse(isset($module_data['book']->info['required']), 'The book module is not required.');
$node = Node::create(['title' => $this->randomString(), 'type' => $content_type->id()]);
@@ -20,17 +20,29 @@ class MigrateBookConfigsTest extends MigrateDrupal6TestBase {
public static $modules = ['book'];
/**
* {@inheritdoc}
* Data provider for testBookSettings().
*
* @return array
* The data for each test scenario.
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_book_settings');
public function providerBookSettings() {
return [
// d6_book_settings was renamed to book_settings, but use the old alias to
// prove that it works.
// @see book_migration_plugins_alter()
['d6_book_settings'],
['book_settings'],
];
}
/**
* Tests migration of book variables to book.settings.yml.
*
* @dataProvider providerBookSettings
*/
public function testBookSettings() {
public function testBookSettings($migration_id) {
$this->executeMigration($migration_id);
$config = $this->config('book.settings');
$this->assertIdentical('book', $config->get('child_type'));
$this->assertSame('book pages', $config->get('block.navigation.mode'));
@@ -0,0 +1,41 @@
<?php
namespace Drupal\Tests\book\Kernel\Migrate\d7;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\Tests\SchemaCheckTestTrait;
/**
* Tests the migration of Book settings.
*
* @group migrate_drupal_7
*/
class MigrateBookConfigsTest extends MigrateDrupal7TestBase {
use SchemaCheckTestTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['book', 'node'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('book_settings');
}
/**
* Tests migration of book variables to book.settings.yml.
*/
public function testBookSettings() {
$config = $this->config('book.settings');
$this->assertSame('book', $config->get('child_type'));
$this->assertSame('all pages', $config->get('block.navigation.mode'));
$this->assertSame(['book'], $config->get('allowed_types'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'book.settings', $config->get());
}
}
@@ -0,0 +1,69 @@
<?php
namespace Drupal\Tests\book\Kernel\Migrate\d7;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\node\Entity\Node;
/**
* Tests migration of book structures from Drupal 7.
*
* @group migrate_drupal_7
*/
class MigrateBookTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'book',
'menu_ui',
'node',
'taxonomy',
'text',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installEntitySchema('taxonomy_term');
$this->installConfig(['node']);
$this->installSchema('book', ['book']);
$this->installSchema('node', ['node_access']);
$this->executeMigrations([
'd7_user_role',
'd7_user',
'd7_node_type',
'd7_node',
'd7_book',
]);
}
/**
* Tests the Drupal 7 book structure to Drupal 8 migration.
*/
public function testBook() {
$nodes = Node::loadMultiple([1, 2, 4, 6]);
$this->assertSame('8', $nodes[1]->book['bid']);
$this->assertSame('6', $nodes[1]->book['pid']);
$this->assertSame('4', $nodes[2]->book['bid']);
$this->assertSame('6', $nodes[2]->book['pid']);
$this->assertSame('4', $nodes[4]->book['bid']);
$this->assertSame('0', $nodes[4]->book['pid']);
$this->assertSame('4', $nodes[6]->book['bid']);
$this->assertSame('4', $nodes[6]->book['pid']);
$tree = \Drupal::service('book.manager')->bookTreeAllData(4);
$this->assertSame('4', $tree['49990 is - The thing about Firefly 4']['link']['nid']);
$this->assertSame('6', $tree['49990 is - The thing about Firefly 4']['below']['50000 Comments are closed :-( 6']['link']['nid']);
$this->assertSame('2', $tree['49990 is - The thing about Firefly 4']['below']['50000 Comments are closed :-( 6']['below']['50000 The thing about Deep Space 9 2']['link']['nid']);
$this->assertSame([], $tree['49990 is - The thing about Firefly 4']['below']['50000 Comments are closed :-( 6']['below']['50000 The thing about Deep Space 9 2']['below']);
}
}
@@ -1,12 +1,14 @@
<?php
namespace Drupal\Tests\book\Kernel\Plugin\migrate\source\d6;
namespace Drupal\Tests\book\Kernel\Plugin\migrate\source;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
use Drupal\book\Plugin\migrate\source\d6\Book as D6Book;
/**
* @covers \Drupal\book\Plugin\migrate\source\d6\Book
* @covers \Drupal\book\Plugin\migrate\source\Book
* @group book
* @group legacy
*/
class BookTest extends MigrateSqlSourceTestBase {
@@ -81,4 +83,18 @@ class BookTest extends MigrateSqlSourceTestBase {
return $tests;
}
/**
* @expectedDeprecation Book is deprecated in Drupal 8.6.x and will be removed before Drupal 9.0.x. Use \Drupal\book\Plugin\migrate\source\Book instead. See https://www.drupal.org/node/2947487 for more information.
*/
public function testDeprecatedPlugin() {
new D6Book(
[],
'd6_book',
[],
$this->prophesize('Drupal\migrate\Plugin\MigrationInterface')->reveal(),
$this->prophesize('Drupal\Core\State\StateInterface')->reveal(),
$this->prophesize('Drupal\Core\Entity\EntityManagerInterface')->reveal()
);
}
}