Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542

This commit is contained in:
Pantheon Automation 2015-08-27 12:03:05 -07:00 committed by Greg Anderson
parent 3b2511d96d
commit 81ccda77eb
2155 changed files with 54307 additions and 46870 deletions

View file

@ -0,0 +1,23 @@
id: d6_book
label: Drupal 6 books
migration_tags:
- Drupal 6
source:
plugin: d6_book
process:
nid: nid
'book/bid': bid
'book/weight': weight
'book/pid':
-
plugin: skip_on_empty
method: process
source: plid
-
plugin: migration
migration: d6_book
destination:
plugin: book
migration_dependencies:
required:
- d6_node

View file

@ -0,0 +1,17 @@
id: d6_book_settings
label: Drupal 6 book configuration
migration_tags:
- Drupal 6
source:
plugin: variable
variables:
- book_child_type
- book_block_mode
- book_allowed_types
process:
child_type: book_child_type
'block/navigation/mode': book_block_mode
allowed_types: book_allowed_types
destination:
plugin: config
config_name: book.settings

View file

@ -7,6 +7,7 @@
namespace Drupal\book\Cache;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Cache\Context\CacheContextInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\RequestStack;
@ -14,6 +15,8 @@ use Symfony\Component\HttpFoundation\RequestStack;
/**
* Defines the book navigation cache context service.
*
* Cache context ID: 'route.book_navigation'.
*
* This allows for book navigation location-aware caching. It depends on:
* - whether the current route represents a book node at all
* - and if so, where in the book hierarchy we are
@ -65,7 +68,27 @@ class BookNavigationCacheContext extends ContainerAware implements CacheContextI
// If we're looking at a book node, get the trail for that node.
$active_trail = $this->container->get('book.manager')
->getActiveTrailIds($node->book['bid'], $node->book);
return 'book.' . implode('|', $active_trail);
return implode('|', $active_trail);
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata() {
// The book active trail depends on the node and data attached to it.
// That information is however not stored as part of the node.
$cacheable_metadata = new CacheableMetadata();
if ($node = $this->requestStack->getCurrentRequest()->get('node')) {
// If the node is part of a book then we can use the cache tag for that
// book. If not, then it can't be optimized away.
if (!empty($node->book['bid'])) {
$cacheable_metadata->addCacheTags(['bid:' . $node->book['bid']]);
}
else {
$cacheable_metadata->setCacheMaxAge(0);
}
}
return $cacheable_metadata;
}
}

View file

@ -0,0 +1,36 @@
<?php
/**
* @file
* Contains \Drupal\book\Plugin\migrate\destination\Book.
*/
namespace Drupal\book\Plugin\migrate\destination;
use Drupal\Core\Entity\EntityInterface;
use Drupal\migrate\Plugin\migrate\destination\EntityContentBase;
use Drupal\migrate\Row;
/**
* @MigrateDestination(
* id = "book",
* provider = "book"
* )
*/
class Book extends EntityContentBase {
/**
* {@inheritdoc}
*/
protected static function getEntityTypeId($plugin_id) {
return 'node';
}
/**
* {@inheritdoc}
*/
protected function updateEntity(EntityInterface $entity, Row $row) {
$entity->book = $row->getDestinationProperty('book');
}
}

View file

@ -0,0 +1,68 @@
<?php
/**
* @file
* Contains \Drupal\book\Plugin\migrate\source\d6\Book.
*/
namespace Drupal\book\Plugin\migrate\source\d6;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 6 book source.
*
* @MigrateSource(
* id = "d6_book"
* )
*/
class Book extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('book', 'b')->fields('b', array('nid', 'bid'));
$query->join('menu_links', 'ml', 'b.mlid = ml.mlid');
$ml_fields = array('mlid', 'plid', 'weight', 'has_children', 'depth');
for ($i = 1; $i <= 9; $i++) {
$field = "p$i";
$ml_fields[] = $field;
$query->orderBy($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 array(
'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.'),
'p2' => $this->t('The second mlid in the materialized path.'),
'p3' => $this->t('The third mlid in the materialized path.'),
'p4' => $this->t('The fourth mlid in the materialized path.'),
'p5' => $this->t('The fifth mlid in the materialized path.'),
'p6' => $this->t('The sixth mlid in the materialized path.'),
'p7' => $this->t('The seventh mlid in the materialized path.'),
'p8' => $this->t('The eight mlid in the materialized path.'),
'p9' => $this->t('The nine mlid in the materialized path.'),
);
}
}

View file

@ -0,0 +1,92 @@
<?php
/**
* @file
* Contains Drupal\book\ProxyClass\BookUninstallValidator.
*/
/**
* This file was generated via php core/scripts/generate-proxy-class.php 'Drupal\book\BookUninstallValidator' "core/modules/book/src".
*/
namespace Drupal\book\ProxyClass {
/**
* Provides a proxy class for \Drupal\book\BookUninstallValidator.
*
* @see \Drupal\Component\ProxyBuilder
*/
class BookUninstallValidator implements \Drupal\Core\Extension\ModuleUninstallValidatorInterface
{
use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
/**
* The id of the original proxied service.
*
* @var string
*/
protected $drupalProxyOriginalServiceId;
/**
* The real proxied service, after it was lazy loaded.
*
* @var \Drupal\book\BookUninstallValidator
*/
protected $service;
/**
* The service container.
*
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
protected $container;
/**
* Constructs a ProxyClass Drupal proxy object.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The container.
* @param string $drupal_proxy_original_service_id
* The service ID of the original service.
*/
public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, $drupal_proxy_original_service_id)
{
$this->container = $container;
$this->drupalProxyOriginalServiceId = $drupal_proxy_original_service_id;
}
/**
* Lazy loads the real service from the container.
*
* @return object
* Returns the constructed real service.
*/
protected function lazyLoadItself()
{
if (!isset($this->service)) {
$this->service = $this->container->get($this->drupalProxyOriginalServiceId);
}
return $this->service;
}
/**
* {@inheritdoc}
*/
public function validate($module)
{
return $this->lazyLoadItself()->validate($module);
}
/**
* {@inheritdoc}
*/
public function setStringTranslation(\Drupal\Core\StringTranslation\TranslationInterface $translation)
{
return $this->lazyLoadItself()->setStringTranslation($translation);
}
}
}

View file

@ -0,0 +1,49 @@
<?php
/**
* @file
* Contains \Drupal\book\Tests\Migrate\d6\MigrateBookConfigsTest.
*/
namespace Drupal\book\Tests\Migrate\d6;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade variables to book.settings.yml.
*
* @group book
*/
class MigrateBookConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('book', 'system', 'node', 'field', 'text', 'entity_reference');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->loadDumps(['Variable.php']);
$this->executeMigration('d6_book_settings');
}
/**
* Tests migration of book variables to book.settings.yml.
*/
public function testBookSettings() {
$config = $this->config('book.settings');
$this->assertIdentical('book', $config->get('child_type'));
$this->assertIdentical('all pages', $config->get('block.navigation.mode'));
$this->assertIdentical(array('book'), $config->get('allowed_types'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'book.settings', $config->get());
}
}

View file

@ -0,0 +1,79 @@
<?php
/**
* @file
* Contains \Drupal\book\Tests\Migrate\d6\MigrateBookTest.
*/
namespace Drupal\book\Tests\Migrate\d6;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
use Drupal\node\Entity\Node;
/**
* Upgrade book structure.
*
* @group book
*/
class MigrateBookTest extends MigrateDrupal6TestBase {
public static $modules = array('book', 'system', 'node', 'field', 'text', 'entity_reference', 'user');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installSchema('book', array('book'));
$this->installSchema('node', array('node_access'));
$id_mappings = array();
for ($i = 4; $i <= 8; $i++) {
$entity = entity_create('node', array(
'type' => 'story',
'title' => "Node $i",
'nid' => $i,
'status' => TRUE,
));
$entity->enforceIsNew();
$entity->save();
$id_mappings['d6_node'][] = 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');
}
/**
* Tests the Drupal 6 book structure to Drupal 8 migration.
*/
public function testBook() {
$nodes = Node::loadMultiple(array(4, 5, 6, 7, 8));
$this->assertIdentical('4', $nodes[4]->book['bid']);
$this->assertIdentical('0', $nodes[4]->book['pid']);
$this->assertIdentical('4', $nodes[5]->book['bid']);
$this->assertIdentical('4', $nodes[5]->book['pid']);
$this->assertIdentical('4', $nodes[6]->book['bid']);
$this->assertIdentical('5', $nodes[6]->book['pid']);
$this->assertIdentical('4', $nodes[7]->book['bid']);
$this->assertIdentical('5', $nodes[7]->book['pid']);
$this->assertIdentical('8', $nodes[8]->book['bid']);
$this->assertIdentical('0', $nodes[8]->book['pid']);
$tree = \Drupal::service('book.manager')->bookTreeAllData(4);
$this->assertIdentical('4', $tree['49990 Node 4 4']['link']['nid']);
$this->assertIdentical('5', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['link']['nid']);
$this->assertIdentical('6', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['link']['nid']);
$this->assertIdentical('7', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['link']['nid']);
$this->assertIdentical(array(), $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['below']);
$this->assertIdentical(array(), $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['below']);
}
}