Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542
This commit is contained in:
parent
3b2511d96d
commit
81ccda77eb
2155 changed files with 54307 additions and 46870 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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') {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue