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

@ -8,7 +8,6 @@ block_content_add_action:
route_name: block_content.add_page
title: 'Add custom block'
appears_on:
- block.admin_display
- block.admin_display_theme
- block.admin_library
- entity.block_content.collection
class: \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction

View file

@ -5,7 +5,6 @@
* Provides page callbacks for custom blocks.
*/
use Drupal\Component\Utility\Xss;
use Drupal\Core\Url;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\block_content\Entity\BlockContent;
@ -28,7 +27,9 @@ function template_preprocess_block_content_add_list(&$variables) {
foreach ($variables['content'] as $type) {
$variables['types'][$type->id()] = array(
'link' => \Drupal::l($type->label(), new Url('block_content.add_form', array('block_content_type' => $type->id()), array('query' => $query))),
'description' => Xss::filterAdmin($type->getDescription()),
'description' => array(
'#markup' => $type->getDescription(),
),
'title' => $type->label(),
'localized_options' => array(
'query' => $query,

View file

@ -16,3 +16,15 @@ block_content.type.*:
description:
type: text
label: 'Description'
migrate.source.d6_box:
type: migrate_source_sql
label: 'Drupal 6 box'
mapping:
constants:
type: mapping
label: 'Constants'
mapping:
type:
type: string
label: 'Type'

View file

@ -0,0 +1,25 @@
id: d6_block_content_body_field
label: Drupal 6 block content body field configuration
migration_tags:
- Drupal 6
source:
# We do an empty source and a proper destination to have an idmap for
# migration_dependencies.
plugin: md_empty
constants:
entity_type: block_content
bundle: basic
name: body
label: Body
display_summary: false
process:
entity_type: 'constants/entity_type'
bundle: 'constants/bundle'
field_name: 'constants/name'
label: 'constants/label'
'settings/display_summary': 'constants/display_summary'
destination:
plugin: entity:field_config
migration_dependencies:
required:
- d6_block_content_type

View file

@ -0,0 +1,16 @@
id: d6_block_content_type
label: Drupal 6 block content type
migration_tags:
- Drupal 6
source:
# We do an empty source and a proper destination to have an idmap for
# migration_dependencies.
plugin: md_empty
constants:
id: basic
label: Basic
process:
id: 'constants/id'
label: 'constants/label'
destination:
plugin: entity:block_content_type

View file

@ -0,0 +1,24 @@
id: d6_custom_block
label: Drupal 6 custom blocks
migration_tags:
- Drupal 6
source:
plugin: d6_box
constants:
type: basic
process:
id: bid
type: 'constants/type'
info: info
'body/format':
plugin: migration
migration: d6_filter_format
source: format
'body/value': body
destination:
plugin: entity:block_content
no_stub: true
migration_dependencies:
required:
- d6_filter_format
- d6_block_content_body_field

View file

@ -224,7 +224,8 @@ class BlockContentForm extends ContentEntityForm {
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
if ($this->entity->isNew()) {
$entity = parent::validateForm($form, $form_state);
if ($entity->isNew()) {
$exists = $this->blockContentStorage->loadByProperties(array('info' => $form_state->getValue(['info', 0, 'value'])));
if (!empty($exists)) {
$form_state->setErrorByName('info', $this->t('A block with description %name already exists.', array(
@ -232,6 +233,7 @@ class BlockContentForm extends ContentEntityForm {
)));
}
}
return $entity;
}
}

View file

@ -7,7 +7,6 @@
namespace Drupal\block_content;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
@ -45,7 +44,7 @@ class BlockContentTypeListBuilder extends ConfigEntityListBuilder {
*/
public function buildRow(EntityInterface $entity) {
$row['type'] = $entity->link();
$row['description'] = Xss::filterAdmin($entity->getDescription());
$row['description']['data']['#markup'] = $entity->getDescription();
return $row + parent::buildRow($entity);
}

View file

@ -0,0 +1,52 @@
<?php
/**
* @file
* Contains \Drupal\block_content\Plugin\migrate\source\d6\Box.
*/
namespace Drupal\block_content\Plugin\migrate\source\d6;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 6 block source from database.
*
* @MigrateSource(
* id = "d6_box"
* )
*/
class Box extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('boxes', 'b')
->fields('b', array('bid', 'body', 'info', 'format'));
$query->orderBy('bid');
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
return array(
'bid' => $this->t('The numeric identifier of the block/box'),
'body' => $this->t('The block/box content'),
'info' => $this->t('Admin title of the block/box.'),
'format' => $this->t('Input format of the custom block/box content.'),
);
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['bid']['type'] = 'integer';
return $ids;
}
}

View file

@ -90,13 +90,15 @@ class BlockContentCacheTagsTest extends EntityCacheTagsTestBase {
// Expected keys, contexts, and tags for the block.
// @see \Drupal\block\BlockViewBuilder::viewMultiple()
$expected_block_cache_keys = ['entity_view', 'block', $block->id()];
$expected_block_cache_contexts = ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme'];
$expected_block_cache_tags = Cache::mergeTags(['block_view', 'rendered'], $block->getCacheTags(), $block->getPlugin()->getCacheTags());
$expected_block_cache_contexts = ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme', 'user.permissions'];
$expected_block_cache_tags = Cache::mergeTags(['block_view', 'rendered'], $block->getCacheTags());
$expected_block_cache_tags = Cache::mergeTags($expected_block_cache_tags, $block->getPlugin()->getCacheTags());
// Expected contexts and tags for the BlockContent entity.
// @see \Drupal\Core\Entity\EntityViewBuilder::getBuildDefaults().
$expected_entity_cache_contexts = ['theme'];
$expected_entity_cache_tags = Cache::mergeTags(['block_content_view'], $this->entity->getCacheTags(), $this->getAdditionalCacheTagsForEntity($this->entity));
$expected_entity_cache_tags = Cache::mergeTags(['block_content_view'], $this->entity->getCacheTags());
$expected_entity_cache_tags = Cache::mergeTags($expected_entity_cache_tags, $this->getAdditionalCacheTagsForEntity($this->entity));
// Verify that what was render cached matches the above expectations.
$cid = $this->createCacheId($expected_block_cache_keys, $expected_block_cache_contexts);

View file

@ -189,6 +189,7 @@ class BlockContentTypeTest extends BlockContentTestBase {
// block configure form.
$path = $theme == $default_theme ? 'admin/structure/block' : "admin/structure/block/list/$theme";
$this->drupalGet($path);
$this->clickLinkPartialName('Place block');
$this->clickLink(t('Add custom block'));
// The seven theme has markup inside the link, we cannot use clickLink().
if ($default_theme == 'seven') {

View file

@ -0,0 +1,62 @@
<?php
/**
* @file
* Contains \Drupal\block_content\Tests\Migrate\d6\MigrateBlockContentTest.
*/
namespace Drupal\block_content\Tests\Migrate\d6;
use Drupal\block_content\Entity\BlockContent;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade custom blocks.
*
* @group block_content
*/
class MigrateBlockContentTest extends MigrateDrupal6TestBase {
static $modules = array('block', 'block_content', 'filter', 'text');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(array('block_content'));
$this->installEntitySchema('block_content');
$this->executeMigration('d6_block_content_type');
$this->executeMigration('d6_block_content_body_field');
$this->prepareMigrations(array(
'd6_filter_format' => array(
array(array(2), array('full_html'))
)
));
$this->loadDumps(['Boxes.php']);
$this->executeMigration('d6_custom_block');
}
/**
* Tests the Drupal 6 custom block to Drupal 8 migration.
*/
public function testBlockMigration() {
/** @var BlockContent $block */
$block = BlockContent::load(1);
$this->assertIdentical('My block 1', $block->label());
$this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time());
$this->assertIdentical('en', $block->language()->getId());
$this->assertIdentical('<h3>My first custom block body</h3>', $block->body->value);
$this->assertIdentical('full_html', $block->body->format);
$block = BlockContent::load(2);
$this->assertIdentical('My block 2', $block->label());
$this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time());
$this->assertIdentical('en', $block->language()->getId());
$this->assertIdentical('<h3>My second custom block body</h3>', $block->body->value);
$this->assertIdentical('full_html', $block->body->format);
}
}

View file

@ -60,6 +60,7 @@ function block_content_test_block_content_insert(BlockContent $block_content) {
// Set the block_content title to the block_content ID and save.
if ($block_content->label() == 'new') {
$block_content->setInfo('BlockContent ' . $block_content->id());
$block_content->setNewRevision(FALSE);
$block_content->save();
}
if ($block_content->label() == 'fail_creation') {

View file

@ -0,0 +1,59 @@
<?php
/**
* @file
* Contains \Drupal\Tests\block_content\Unit\Plugin\migrate\source\d6\BoxTest.
*/
namespace Drupal\Tests\block_content\Unit\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 block boxes source plugin.
*
* @group block_content
*/
class BoxTest extends MigrateSqlSourceTestCase {
// The plugin system is not working during unit testing so the source plugin
// class needs to be manually specified.
const PLUGIN_CLASS = 'Drupal\block_content\Plugin\migrate\source\d6\Box';
// The fake Migration configuration entity.
protected $migrationConfiguration = array(
// The ID of the entity, can be any string.
'id' => 'test',
// Leave it empty for now.
'idlist' => array(),
'source' => array(
'plugin' => 'd6_boxes',
),
);
// We need to set up the database contents; it's easier to do that below.
// These are sample result queries.
protected $expectedResults = array(
array(
'bid' => 1,
'body' => '<p>I made some custom content.</p>',
'info' => 'Static Block',
'format' => 1,
),
array(
'bid' => 2,
'body' => '<p>I made some more custom content.</p>',
'info' => 'Test Content',
'format' => 1,
),
);
/**
* Prepopulate contents with results.
*/
protected function setUp() {
$this->databaseContents['boxes'] = $this->expectedResults;
parent::setUp();
}
}