Issue #2281393 by ultimike, mrjmd, bdone, quietone, Xano, vendion, benjy, brockfanning, alexpott: D6->D8 Blocks - Custom titles not imported
parent
4d185faff1
commit
3429084f46
|
@ -74,7 +74,6 @@ process:
|
||||||
help: help
|
help: help
|
||||||
header: header
|
header: header
|
||||||
footer: footer
|
footer: footer
|
||||||
label: title
|
|
||||||
weight: weight
|
weight: weight
|
||||||
settings:
|
settings:
|
||||||
plugin: block_settings
|
plugin: block_settings
|
||||||
|
@ -82,6 +81,7 @@ process:
|
||||||
- '@plugin'
|
- '@plugin'
|
||||||
- delta
|
- delta
|
||||||
- settings
|
- settings
|
||||||
|
- title
|
||||||
visibility:
|
visibility:
|
||||||
plugin: block_visibility
|
plugin: block_visibility
|
||||||
source:
|
source:
|
||||||
|
|
|
@ -75,7 +75,6 @@ process:
|
||||||
help: help
|
help: help
|
||||||
header: header
|
header: header
|
||||||
footer: footer
|
footer: footer
|
||||||
label: title
|
|
||||||
weight: weight
|
weight: weight
|
||||||
settings:
|
settings:
|
||||||
plugin: block_settings
|
plugin: block_settings
|
||||||
|
@ -83,6 +82,7 @@ process:
|
||||||
- '@plugin'
|
- '@plugin'
|
||||||
- delta
|
- delta
|
||||||
- settings
|
- settings
|
||||||
|
- title
|
||||||
visibility:
|
visibility:
|
||||||
plugin: block_visibility
|
plugin: block_visibility
|
||||||
source:
|
source:
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
namespace Drupal\block\Plugin\migrate\process;
|
namespace Drupal\block\Plugin\migrate\process;
|
||||||
|
|
||||||
|
use Drupal\block\BlockInterface;
|
||||||
use Drupal\migrate\MigrateExecutableInterface;
|
use Drupal\migrate\MigrateExecutableInterface;
|
||||||
use Drupal\migrate\ProcessPluginBase;
|
use Drupal\migrate\ProcessPluginBase;
|
||||||
use Drupal\migrate\Row;
|
use Drupal\migrate\Row;
|
||||||
|
@ -24,8 +25,15 @@ class BlockSettings extends ProcessPluginBase {
|
||||||
* Set the block configuration.
|
* Set the block configuration.
|
||||||
*/
|
*/
|
||||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||||
list($plugin, $delta, $old_settings) = $value;
|
list($plugin, $delta, $old_settings, $title) = $value;
|
||||||
$settings = array();
|
$settings = array();
|
||||||
|
$settings['label'] = $title;
|
||||||
|
if ($title) {
|
||||||
|
$settings['label_display'] = BlockInterface::BLOCK_LABEL_VISIBLE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$settings['label_display'] = '0';
|
||||||
|
}
|
||||||
switch ($plugin) {
|
switch ($plugin) {
|
||||||
case 'aggregator_feed_block':
|
case 'aggregator_feed_block':
|
||||||
list(, $id) = explode('-', $delta);
|
list(, $id) = explode('-', $delta);
|
||||||
|
|
|
@ -69,14 +69,22 @@ class MigrateBlockTest extends MigrateDrupal6TestBase {
|
||||||
* The theme.
|
* The theme.
|
||||||
* @param string $weight
|
* @param string $weight
|
||||||
* The block weight.
|
* The block weight.
|
||||||
|
* @param string $label
|
||||||
|
* The block label.
|
||||||
|
* @param string $label_display
|
||||||
|
* The block label display setting.
|
||||||
*/
|
*/
|
||||||
public function assertEntity($id, $visibility, $region, $theme, $weight) {
|
public function assertEntity($id, $visibility, $region, $theme, $weight, $label, $label_display) {
|
||||||
$block = Block::load($id);
|
$block = Block::load($id);
|
||||||
$this->assertTrue($block instanceof Block);
|
$this->assertTrue($block instanceof Block);
|
||||||
$this->assertIdentical($visibility, $block->getVisibility());
|
$this->assertIdentical($visibility, $block->getVisibility());
|
||||||
$this->assertIdentical($region, $block->getRegion());
|
$this->assertIdentical($region, $block->getRegion());
|
||||||
$this->assertIdentical($theme, $block->getTheme());
|
$this->assertIdentical($theme, $block->getTheme());
|
||||||
$this->assertIdentical($weight, $block->getWeight());
|
$this->assertIdentical($weight, $block->getWeight());
|
||||||
|
|
||||||
|
$config = $this->config('block.block.' . $id);
|
||||||
|
$this->assertIdentical($label, $config->get('settings.label'));
|
||||||
|
$this->assertIdentical($label_display, $config->get('settings.label_display'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,10 +99,10 @@ class MigrateBlockTest extends MigrateDrupal6TestBase {
|
||||||
$visibility['request_path']['id'] = 'request_path';
|
$visibility['request_path']['id'] = 'request_path';
|
||||||
$visibility['request_path']['negate'] = TRUE;
|
$visibility['request_path']['negate'] = TRUE;
|
||||||
$visibility['request_path']['pages'] = "<front>\n/node/1\n/blog/*";
|
$visibility['request_path']['pages'] = "<front>\n/node/1\n/blog/*";
|
||||||
$this->assertEntity('user', $visibility, 'sidebar_first', 'bartik', 0);
|
$this->assertEntity('user', $visibility, 'sidebar_first', 'bartik', 0, '', '0');
|
||||||
|
|
||||||
$visibility = [];
|
$visibility = [];
|
||||||
$this->assertEntity('user_1', $visibility, 'sidebar_first', 'bartik', 0);
|
$this->assertEntity('user_1', $visibility, 'sidebar_first', 'bartik', 0, '', '0');
|
||||||
|
|
||||||
$visibility['user_role']['id'] = 'user_role';
|
$visibility['user_role']['id'] = 'user_role';
|
||||||
$roles['authenticated'] = 'authenticated';
|
$roles['authenticated'] = 'authenticated';
|
||||||
|
@ -102,7 +110,7 @@ class MigrateBlockTest extends MigrateDrupal6TestBase {
|
||||||
$context_mapping['user'] = '@user.current_user_context:current_user';
|
$context_mapping['user'] = '@user.current_user_context:current_user';
|
||||||
$visibility['user_role']['context_mapping'] = $context_mapping;
|
$visibility['user_role']['context_mapping'] = $context_mapping;
|
||||||
$visibility['user_role']['negate'] = FALSE;
|
$visibility['user_role']['negate'] = FALSE;
|
||||||
$this->assertEntity('user_2', $visibility, 'sidebar_second', 'bartik', -9);
|
$this->assertEntity('user_2', $visibility, 'sidebar_second', 'bartik', -9, '', '0');
|
||||||
|
|
||||||
$visibility = [];
|
$visibility = [];
|
||||||
$visibility['user_role']['id'] = 'user_role';
|
$visibility['user_role']['id'] = 'user_role';
|
||||||
|
@ -112,32 +120,32 @@ class MigrateBlockTest extends MigrateDrupal6TestBase {
|
||||||
$context_mapping['user'] = '@user.current_user_context:current_user';
|
$context_mapping['user'] = '@user.current_user_context:current_user';
|
||||||
$visibility['user_role']['context_mapping'] = $context_mapping;
|
$visibility['user_role']['context_mapping'] = $context_mapping;
|
||||||
$visibility['user_role']['negate'] = FALSE;
|
$visibility['user_role']['negate'] = FALSE;
|
||||||
$this->assertEntity('user_3', $visibility, 'sidebar_second', 'bartik', -6);
|
$this->assertEntity('user_3', $visibility, 'sidebar_second', 'bartik', -6, '', '0');
|
||||||
|
|
||||||
// Check system block
|
// Check system block
|
||||||
$visibility = [];
|
$visibility = [];
|
||||||
$visibility['request_path']['id'] = 'request_path';
|
$visibility['request_path']['id'] = 'request_path';
|
||||||
$visibility['request_path']['negate'] = TRUE;
|
$visibility['request_path']['negate'] = TRUE;
|
||||||
$visibility['request_path']['pages'] = '/node/1';
|
$visibility['request_path']['pages'] = '/node/1';
|
||||||
$this->assertEntity('system', $visibility, 'footer', 'bartik', -5);
|
$this->assertEntity('system', $visibility, 'footer', 'bartik', -5, '', '0');
|
||||||
|
|
||||||
// Check menu blocks
|
// Check menu blocks
|
||||||
$visibility = [];
|
$visibility = [];
|
||||||
$this->assertEntity('menu', $visibility, 'header', 'bartik', -5);
|
$this->assertEntity('menu', $visibility, 'header', 'bartik', -5, '', '0');
|
||||||
|
|
||||||
// Check custom blocks
|
// Check custom blocks
|
||||||
$visibility['request_path']['id'] = 'request_path';
|
$visibility['request_path']['id'] = 'request_path';
|
||||||
$visibility['request_path']['negate'] = FALSE;
|
$visibility['request_path']['negate'] = FALSE;
|
||||||
$visibility['request_path']['pages'] = '<front>';
|
$visibility['request_path']['pages'] = '<front>';
|
||||||
$this->assertEntity('block', $visibility, 'content', 'bartik', 0);
|
$this->assertEntity('block', $visibility, 'content', 'bartik', 0, 'Static Block', 'visible');
|
||||||
|
|
||||||
$visibility['request_path']['id'] = 'request_path';
|
$visibility['request_path']['id'] = 'request_path';
|
||||||
$visibility['request_path']['negate'] = FALSE;
|
$visibility['request_path']['negate'] = FALSE;
|
||||||
$visibility['request_path']['pages'] = '/node';
|
$visibility['request_path']['pages'] = '/node';
|
||||||
$this->assertEntity('block_1', $visibility, 'sidebar_second', 'bluemarine', -4);
|
$this->assertEntity('block_1', $visibility, 'sidebar_second', 'bluemarine', -4, 'Another Static Block', 'visible');
|
||||||
|
|
||||||
$visibility = [];
|
$visibility = [];
|
||||||
$this->assertEntity('block_2', $visibility, 'right', 'test_theme', -7);
|
$this->assertEntity('block_2', $visibility, 'right', 'test_theme', -7, '', '0');
|
||||||
|
|
||||||
// Custom block with php code is not migrated.
|
// Custom block with php code is not migrated.
|
||||||
$block = Block::load('block_3');
|
$block = Block::load('block_3');
|
||||||
|
|
|
@ -77,8 +77,13 @@ class MigrateBlockTest extends MigrateDrupal7TestBase {
|
||||||
* The theme.
|
* The theme.
|
||||||
* @param string $weight
|
* @param string $weight
|
||||||
* The block weight.
|
* The block weight.
|
||||||
|
* @param string $label
|
||||||
|
* The block label.
|
||||||
|
* @param string $label_display
|
||||||
|
* The block label display setting.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public function assertEntity($id, $plugin_id, array $roles, $pages, $region, $theme, $weight) {
|
public function assertEntity($id, $plugin_id, array $roles, $pages, $region, $theme, $weight, $label, $label_display) {
|
||||||
$block = Block::load($id);
|
$block = Block::load($id);
|
||||||
$this->assertTrue($block instanceof Block);
|
$this->assertTrue($block instanceof Block);
|
||||||
/** @var \Drupal\block\BlockInterface $block */
|
/** @var \Drupal\block\BlockInterface $block */
|
||||||
|
@ -96,24 +101,28 @@ class MigrateBlockTest extends MigrateDrupal7TestBase {
|
||||||
$this->assertIdentical($region, $block->getRegion());
|
$this->assertIdentical($region, $block->getRegion());
|
||||||
$this->assertIdentical($theme, $block->getTheme());
|
$this->assertIdentical($theme, $block->getTheme());
|
||||||
$this->assertIdentical($weight, $block->getWeight());
|
$this->assertIdentical($weight, $block->getWeight());
|
||||||
|
|
||||||
|
$config = $this->config('block.block.' . $id);
|
||||||
|
$this->assertIdentical($label, $config->get('settings.label'));
|
||||||
|
$this->assertIdentical($label_display, $config->get('settings.label_display'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the block migration.
|
* Tests the block migration.
|
||||||
*/
|
*/
|
||||||
public function testBlockMigration() {
|
public function testBlockMigration() {
|
||||||
$this->assertEntity('bartik_system_main', 'system_main_block', [], '', 'content', 'bartik', 0);
|
$this->assertEntity('bartik_system_main', 'system_main_block', [], '', 'content', 'bartik', 0, '', '0');
|
||||||
$this->assertEntity('bartik_search_form', 'search_form_block', [], '', 'sidebar_first', 'bartik', -1);
|
$this->assertEntity('bartik_search_form', 'search_form_block', [], '', 'sidebar_first', 'bartik', -1, '', '0');
|
||||||
$this->assertEntity('bartik_user_login', 'user_login_block', [], '', 'sidebar_first', 'bartik', 0);
|
$this->assertEntity('bartik_user_login', 'user_login_block', [], '', 'sidebar_first', 'bartik', 0, '', '0');
|
||||||
$this->assertEntity('bartik_system_powered-by', 'system_powered_by_block', [], '', 'footer', 'bartik', 10);
|
$this->assertEntity('bartik_system_powered-by', 'system_powered_by_block', [], '', 'footer', 'bartik', 10, '', '0');
|
||||||
$this->assertEntity('seven_system_main', 'system_main_block', [], '', 'content', 'seven', 0);
|
$this->assertEntity('seven_system_main', 'system_main_block', [], '', 'content', 'seven', 0, '', '0');
|
||||||
$this->assertEntity('seven_user_login', 'user_login_block', [], '', 'content', 'seven', 10);
|
$this->assertEntity('seven_user_login', 'user_login_block', [], '', 'content', 'seven', 10, '', '0');
|
||||||
|
|
||||||
// The d7_custom_block migration should have migrated a block containing a
|
// The d7_custom_block migration should have migrated a block containing a
|
||||||
// mildly amusing limerick. We'll need its UUID to determine
|
// mildly amusing limerick. We'll need its UUID to determine
|
||||||
// bartik_block_1's plugin ID.
|
// bartik_block_1's plugin ID.
|
||||||
$uuid = BlockContent::load(1)->uuid();
|
$uuid = BlockContent::load(1)->uuid();
|
||||||
$this->assertEntity('bartik_block_1', 'block_content:' . $uuid, ['authenticated'], '', 'highlighted', 'bartik', 0);
|
$this->assertEntity('bartik_block_1', 'block_content:' . $uuid, ['authenticated'], '', 'highlighted', 'bartik', 0, 'Mildly amusing limerick of the day', 'visible');
|
||||||
|
|
||||||
// Assert that disabled blocks (or enabled blocks whose plugin IDs could
|
// Assert that disabled blocks (or enabled blocks whose plugin IDs could
|
||||||
// be resolved) did not migrate.
|
// be resolved) did not migrate.
|
||||||
|
|
Loading…
Reference in New Issue