composer update
This commit is contained in:
parent
f6abc3dce2
commit
71dfaca858
1753 changed files with 45274 additions and 14619 deletions
|
@ -93,7 +93,8 @@
|
|||
*/
|
||||
Drupal.behaviors.blockHighlightPlacement = {
|
||||
attach(context, settings) {
|
||||
if (settings.blockPlacement) {
|
||||
// Ensure that the block we are attempting to scroll to actually exists.
|
||||
if (settings.blockPlacement && $('.js-block-placed').length) {
|
||||
$(context)
|
||||
.find('[data-drupal-selector="edit-blocks"]')
|
||||
.once('block-highlight')
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
Drupal.behaviors.blockHighlightPlacement = {
|
||||
attach: function attach(context, settings) {
|
||||
if (settings.blockPlacement) {
|
||||
if (settings.blockPlacement && $('.js-block-placed').length) {
|
||||
$(context).find('[data-drupal-selector="edit-blocks"]').once('block-highlight').each(function () {
|
||||
var $container = $(this);
|
||||
|
||||
|
|
|
@ -193,6 +193,9 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
|
|||
if ($this->request->query->has('block-placement')) {
|
||||
$placement = $this->request->query->get('block-placement');
|
||||
$form['#attached']['drupalSettings']['blockPlacement'] = $placement;
|
||||
// Remove the block placement from the current request so that it is not
|
||||
// passed on to any redirect destinations.
|
||||
$this->request->query->remove('block-placement');
|
||||
}
|
||||
|
||||
// Loop over each region and build blocks.
|
||||
|
@ -378,9 +381,6 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
|
|||
$entity->save();
|
||||
}
|
||||
$this->messenger->addStatus($this->t('The block settings have been updated.'));
|
||||
|
||||
// Remove any previously set block placement.
|
||||
$this->request->query->remove('block-placement');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\block\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\block\Plugin\migrate\source\Block;
|
||||
|
||||
/**
|
||||
* Gets i18n block data from source database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_block_translation",
|
||||
* source_module = "i18n_block"
|
||||
* )
|
||||
*/
|
||||
class BlockTranslation extends Block {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Let the parent set the block table to use, but do not use the parent
|
||||
// query. Instead build a query so can use an inner join to the selected
|
||||
// block table.
|
||||
parent::query();
|
||||
$query = $this->select('i18n_string', 'i18n')
|
||||
->fields('i18n')
|
||||
->fields('b', [
|
||||
'bid',
|
||||
'module',
|
||||
'delta',
|
||||
'theme',
|
||||
'status',
|
||||
'weight',
|
||||
'region',
|
||||
'custom',
|
||||
'visibility',
|
||||
'pages',
|
||||
'title',
|
||||
'cache',
|
||||
'i18n_mode',
|
||||
])
|
||||
->fields('lt', [
|
||||
'lid',
|
||||
'translation',
|
||||
'language',
|
||||
'plid',
|
||||
'plural',
|
||||
'i18n_status',
|
||||
])
|
||||
->condition('i18n_mode', 1);
|
||||
$query->leftjoin($this->blockTable, 'b', ('b.delta = i18n.objectid'));
|
||||
$query->leftjoin('locales_target', 'lt', 'lt.lid = i18n.lid');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'bid' => $this->t('The block numeric identifier.'),
|
||||
'module' => $this->t('The module providing the block.'),
|
||||
'delta' => $this->t("The block's delta."),
|
||||
'theme' => $this->t('Which theme the block is placed in.'),
|
||||
'status' => $this->t('Block enabled status'),
|
||||
'weight' => $this->t('Block weight within region'),
|
||||
'region' => $this->t('Theme region within which the block is set'),
|
||||
'visibility' => $this->t('Visibility'),
|
||||
'pages' => $this->t('Pages list.'),
|
||||
'title' => $this->t('Block title.'),
|
||||
'cache' => $this->t('Cache rule.'),
|
||||
'i18n_mode' => $this->t('Multilingual mode'),
|
||||
'lid' => $this->t('Language string ID'),
|
||||
'textgroup' => $this->t('A module defined group of translations'),
|
||||
'context' => $this->t('Full string ID for quick search: type:objectid:property.'),
|
||||
'objectid' => $this->t('Object ID'),
|
||||
'type' => $this->t('Object type for this string'),
|
||||
'property' => $this->t('Object property for this string'),
|
||||
'objectindex' => $this->t('Integer value of Object ID'),
|
||||
'format' => $this->t('The {filter_format}.format of the string'),
|
||||
'translation' => $this->t('Translation'),
|
||||
'language' => $this->t('Language code'),
|
||||
'plid' => $this->t('Parent lid'),
|
||||
'plural' => $this->t('Plural index number'),
|
||||
'i18n_status' => $this->t('Translation needs update'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['delta']['type'] = 'string';
|
||||
$ids['delta']['alias'] = 'b';
|
||||
$ids['language']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\block_test\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
|
||||
/**
|
||||
* Provides a context-aware block that uses a not-passed, non-required context.
|
||||
*
|
||||
* @Block(
|
||||
* id = "test_context_aware_no_valid_context_options",
|
||||
* admin_label = @Translation("Test context-aware block - no valid context options"),
|
||||
* context_definitions = {
|
||||
* "email" = @ContextDefinition("email", required = FALSE)
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class TestContextAwareNoValidContextOptionsBlock extends BlockBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build() {
|
||||
return [
|
||||
'#markup' => 'Rendered block with no valid context options',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,8 @@
|
|||
namespace Drupal\Tests\block\Functional;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
|
@ -239,6 +241,13 @@ class BlockUiTest extends BrowserTestBase {
|
|||
$this->assertText('User context found.');
|
||||
$this->assertRaw($expected_text);
|
||||
|
||||
// Test context mapping form element is not visible if there are no valid
|
||||
// context options for the block (the test_context_aware_no_valid_context_options
|
||||
// block has one context defined which is not available for it on the
|
||||
// Block Layout interface).
|
||||
$this->drupalGet('admin/structure/block/add/test_context_aware_no_valid_context_options/classy');
|
||||
$this->assertSession()->fieldNotExists('edit-settings-context-mapping-email');
|
||||
|
||||
// Test context mapping allows empty selection for optional contexts.
|
||||
$this->drupalGet('admin/structure/block/manage/testcontextawareblock');
|
||||
$edit = [
|
||||
|
@ -281,6 +290,24 @@ class BlockUiTest extends BrowserTestBase {
|
|||
* Tests the block placement indicator.
|
||||
*/
|
||||
public function testBlockPlacementIndicator() {
|
||||
// Test the block placement indicator with using the domain as URL language
|
||||
// indicator. This causes destination query parameters to be absolute URLs.
|
||||
\Drupal::service('module_installer')->install(['language', 'locale']);
|
||||
$this->container = \Drupal::getContainer();
|
||||
ConfigurableLanguage::createFromLangcode('it')->save();
|
||||
$config = $this->config('language.types');
|
||||
$config->set('negotiation.language_interface.enabled', [
|
||||
LanguageNegotiationUrl::METHOD_ID => -10,
|
||||
]);
|
||||
$config->save();
|
||||
$config = $this->config('language.negotiation');
|
||||
$config->set('url.source', LanguageNegotiationUrl::CONFIG_DOMAIN);
|
||||
$config->set('url.domains', [
|
||||
'en' => \Drupal::request()->getHost(),
|
||||
'it' => 'it.example.com',
|
||||
]);
|
||||
$config->save();
|
||||
|
||||
// Select the 'Powered by Drupal' block to be placed.
|
||||
$block = [];
|
||||
$block['id'] = strtolower($this->randomMachineName());
|
||||
|
@ -289,11 +316,30 @@ class BlockUiTest extends BrowserTestBase {
|
|||
|
||||
// After adding a block, it will indicate which block was just added.
|
||||
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block', $block, t('Save block'));
|
||||
$this->assertUrl('admin/structure/block/list/classy?block-placement=' . Html::getClass($block['id']));
|
||||
$this->assertSession()->addressEquals('admin/structure/block/list/classy?block-placement=' . Html::getClass($block['id']));
|
||||
|
||||
// Resaving the block page will remove the block indicator.
|
||||
// Resaving the block page will remove the block placement indicator.
|
||||
$this->drupalPostForm(NULL, [], t('Save blocks'));
|
||||
$this->assertUrl('admin/structure/block/list/classy');
|
||||
$this->assertSession()->addressEquals('admin/structure/block/list/classy');
|
||||
|
||||
// Place another block and test the remove functionality works with the
|
||||
// block placement indicator. Click the first 'Place block' link to bring up
|
||||
// the list of blocks to place in the first available region.
|
||||
$this->clickLink('Place block');
|
||||
// Select the first available block.
|
||||
$this->clickLink('Place block');
|
||||
$block = [];
|
||||
$block['id'] = strtolower($this->randomMachineName());
|
||||
$block['theme'] = 'classy';
|
||||
$this->submitForm([], 'Save block');
|
||||
$this->assertSession()->addressEquals('admin/structure/block/list/classy?block-placement=' . Html::getClass($block['id']));
|
||||
|
||||
// Removing a block will remove the block placement indicator.
|
||||
$this->clickLink('Remove');
|
||||
$this->submitForm([], 'Remove');
|
||||
// @todo https://www.drupal.org/project/drupal/issues/2980527 this should be
|
||||
// 'admin/structure/block/list/classy' but there is a bug.
|
||||
$this->assertSession()->addressEquals('admin/structure/block');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\block\Kernel\Migrate\d7;
|
||||
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of i18n block translations.
|
||||
*
|
||||
* @group migrate_drupal_7
|
||||
*/
|
||||
class MigrateBlockContentTranslationTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'node',
|
||||
'text',
|
||||
'aggregator',
|
||||
'book',
|
||||
'block',
|
||||
'comment',
|
||||
'forum',
|
||||
'views',
|
||||
'block_content',
|
||||
'config_translation',
|
||||
'content_translation',
|
||||
'language',
|
||||
'statistics',
|
||||
'taxonomy',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installConfig(['block']);
|
||||
$this->installConfig(['block_content']);
|
||||
$this->installEntitySchema('block_content');
|
||||
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd7_filter_format',
|
||||
'block_content_type',
|
||||
'block_content_body_field',
|
||||
'd7_custom_block',
|
||||
'd7_user_role',
|
||||
'd7_block',
|
||||
'd7_block_translation',
|
||||
]);
|
||||
block_rebuild();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the migration of block title translation.
|
||||
*/
|
||||
public function testBlockContentTranslation() {
|
||||
/** @var \Drupal\language\ConfigurableLanguageManagerInterface $language_manager */
|
||||
$language_manager = $this->container->get('language_manager');
|
||||
|
||||
$config = $language_manager->getLanguageConfigOverride('fr', 'block.block.bartik_user_login');
|
||||
$this->assertSame('fr - User login title', $config->get('settings.label'));
|
||||
}
|
||||
|
||||
}
|
|
@ -112,10 +112,10 @@ class MigrateBlockTest extends MigrateDrupal7TestBase {
|
|||
public function testBlockMigration() {
|
||||
$this->assertEntity('bartik_system_main', 'system_main_block', [], '', 'content', 'bartik', 0, '', '0');
|
||||
$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, '', '0');
|
||||
$this->assertEntity('bartik_user_login', 'user_login_block', [], '', 'sidebar_first', 'bartik', 0, 'User login title', 'visible');
|
||||
$this->assertEntity('bartik_system_powered_by', 'system_powered_by_block', [], '', 'footer_fifth', 'bartik', 10, '', '0');
|
||||
$this->assertEntity('seven_system_main', 'system_main_block', [], '', 'content', 'seven', 0, '', '0');
|
||||
$this->assertEntity('seven_user_login', 'user_login_block', [], '', 'content', 'seven', 10, '', '0');
|
||||
$this->assertEntity('seven_user_login', 'user_login_block', [], '', 'content', 'seven', 10, 'User login title', 'visible');
|
||||
|
||||
// The d7_custom_block migration should have migrated a block containing a
|
||||
// mildly amusing limerick. We'll need its UUID to determine
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\block\Kernel\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests i18n block source plugin.
|
||||
*
|
||||
* @covers \Drupal\block\Plugin\migrate\source\d7\BlockTranslation
|
||||
*
|
||||
* @group content_translation
|
||||
*/
|
||||
class BlockTranslationTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['block', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['block'] = [
|
||||
[
|
||||
'bid' => 1,
|
||||
'module' => 'system',
|
||||
'delta' => 'main',
|
||||
'theme' => 'bartik',
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'region' => 'content',
|
||||
'custom' => '0',
|
||||
'visibility' => 0,
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => -1,
|
||||
'i18n_mode' => 0,
|
||||
],
|
||||
[
|
||||
'bid' => 2,
|
||||
'module' => 'system',
|
||||
'delta' => 'navigation',
|
||||
'theme' => 'bartik',
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'region' => 'sidebar_first',
|
||||
'custom' => '0',
|
||||
'visibility' => 0,
|
||||
'pages' => '',
|
||||
'title' => 'Navigation',
|
||||
'cache' => -1,
|
||||
'i18n_mode' => 1,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['block_role'] = [
|
||||
[
|
||||
'module' => 'block',
|
||||
'delta' => 1,
|
||||
'rid' => 2,
|
||||
],
|
||||
[
|
||||
'module' => 'block',
|
||||
'delta' => 2,
|
||||
'rid' => 2,
|
||||
],
|
||||
[
|
||||
'module' => 'block',
|
||||
'delta' => 2,
|
||||
'rid' => 100,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['i18n_string'] = [
|
||||
[
|
||||
'lid' => 1,
|
||||
'textgroup' => 'block',
|
||||
'context' => '1',
|
||||
'objectid' => 'navigation',
|
||||
'type' => 'system',
|
||||
'property' => 'title',
|
||||
'objectindex' => 0,
|
||||
'format' => '',
|
||||
],
|
||||
];
|
||||
|
||||
$tests[0]['source_data']['locales_target'] = [
|
||||
[
|
||||
'lid' => 1,
|
||||
'translation' => 'fr - Navigation',
|
||||
'language' => 'fr',
|
||||
'plid' => 0,
|
||||
'plural' => 0,
|
||||
'i18n_status' => 0,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['role'] = [
|
||||
[
|
||||
'rid' => 2,
|
||||
'name' => 'authenticated user',
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['system'] = [
|
||||
[
|
||||
'filename' => 'modules/system/system.module',
|
||||
'name' => 'system',
|
||||
'type' => 'module',
|
||||
'owner' => '',
|
||||
'status' => '1',
|
||||
'throttle' => '0',
|
||||
'bootstrap' => '0',
|
||||
'schema_version' => '7055',
|
||||
'weight' => '0',
|
||||
'info' => 'a:0:{}',
|
||||
],
|
||||
];
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'bid' => 2,
|
||||
'module' => 'system',
|
||||
'delta' => 'navigation',
|
||||
'theme' => 'bartik',
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'region' => 'sidebar_first',
|
||||
'custom' => '0',
|
||||
'visibility' => 0,
|
||||
'pages' => '',
|
||||
'title' => 'Navigation',
|
||||
'cache' => -1,
|
||||
'i18n_mode' => 1,
|
||||
'lid' => 1,
|
||||
'translation' => 'fr - Navigation',
|
||||
'language' => 'fr',
|
||||
'plid' => 0,
|
||||
'plural' => 0,
|
||||
'i18n_status' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue