diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index f3975df1270..04e94c0452f 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -279,14 +279,12 @@ function _block_get_renderable_region($list = array()) {
}
}
else {
- $key_components = explode('.', $key);
- $id = array_pop($key_components);
$build[$key] = array(
'#block' => $block,
'#weight' => $block->get('weight'),
'#pre_render' => array('_block_get_renderable_block'),
'#cache' => array(
- 'keys' => array($id, $settings['module']),
+ 'keys' => array($key, $settings['module']),
'granularity' => $settings['cache'],
'bin' => 'block',
'tags' => array('content' => TRUE),
@@ -383,9 +381,15 @@ function block_theme_initialize($theme) {
$regions = system_region_list($theme, REGIONS_VISIBLE);
$default_theme_blocks = entity_load_multiple_by_properties('block', array('theme' => $default_theme));
foreach ($default_theme_blocks as $default_theme_block_id => $default_theme_block) {
- list(, $machine_name) = explode('.', $default_theme_block_id);
+ if (strpos($default_theme_block_id, $default_theme . '_') === 0) {
+ $id = str_replace($default_theme, $theme, $default_theme_block_id);
+ }
+ else {
+ $id = $theme . '_' . $default_theme_block_id;
+ }
$block = $default_theme_block->createDuplicate();
- $block->set('id', $theme . '.' . $machine_name);
+ $block->set('id', $id);
+ $block->set('theme', $theme);
// If the region isn't supported by the theme, assign the block to the
// theme's default region.
if (!isset($regions[$block->get('region')])) {
@@ -559,9 +563,7 @@ function template_preprocess_block(&$variables) {
// Create a valid HTML ID and make sure it is unique.
if ($id = $variables['elements']['#block']->id()) {
- $config_id = explode('.', $id);
- $machine_name = array_pop($config_id);
- $variables['attributes']['id'] = drupal_html_id('block-' . $machine_name);
+ $variables['attributes']['id'] = drupal_html_id('block-' . $id);
}
}
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php
index ff36e80f6cb..e94e2215100 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php
@@ -149,7 +149,7 @@ class CustomBlockCreationTest extends CustomBlockTestBase {
// Place the block.
$instance = array(
- 'machine_name' => drupal_strtolower($edit['info']),
+ 'id' => drupal_strtolower($edit['info']),
'settings[label]' => $edit['info'],
'region' => 'sidebar_first',
);
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php
index c51be016f5e..54b5d6f7524 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php
@@ -104,7 +104,7 @@ class CustomBlockFieldTest extends CustomBlockTestBase {
$url = 'admin/structure/block/add/custom_block:' . $block->uuid() . '/' . \Drupal::config('system.theme')->get('default');
// Place the block.
$instance = array(
- 'machine_name' => drupal_strtolower($edit['info']),
+ 'id' => drupal_strtolower($edit['info']),
'settings[label]' => $edit['info'],
'region' => 'sidebar_first',
);
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php
index 18e55df7111..ab67e9b2df8 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php
@@ -186,7 +186,7 @@ class CustomBlockTypeTest extends CustomBlockTestBase {
$destination = 'admin/structure/block/add/custom_block:' . $block->uuid() . '/' . $theme;
$this->assertUrl(url($destination, array('absolute' => TRUE)));
$this->drupalPostForm(NULL, array(), t('Save block'));
- $this->assertUrl(url("admin/structure/block/list/$theme", array('absolute' => TRUE, 'query' => array('block-placement' => drupal_html_class($theme . '.' . $edit['info'])))));
+ $this->assertUrl(url("admin/structure/block/list/$theme", array('absolute' => TRUE, 'query' => array('block-placement' => drupal_html_class($edit['info'])))));
}
else {
$this->fail('Could not load created block.');
diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php
index 4a4d1fb9d0f..92d36966437 100644
--- a/core/modules/block/lib/Drupal/block/BlockFormController.php
+++ b/core/modules/block/lib/Drupal/block/BlockFormController.php
@@ -93,14 +93,10 @@ class BlockFormController extends EntityFormController {
public function form(array $form, array &$form_state) {
$entity = $this->entity;
$form['#tree'] = TRUE;
- $form['id'] = array(
- '#type' => 'value',
- '#value' => $entity->id(),
- );
$form['settings'] = $entity->getPlugin()->buildConfigurationForm(array(), $form_state);
// If creating a new block, calculate a safe default machine name.
- $form['machine_name'] = array(
+ $form['id'] = array(
'#type' => 'machine_name',
'#maxlength' => 64,
'#description' => $this->t('A unique name for this block instance. Must be alpha-numeric and underscore separated.'),
@@ -294,15 +290,6 @@ class BlockFormController extends EntityFormController {
public function validate(array $form, array &$form_state) {
parent::validate($form, $form_state);
- $entity = $this->entity;
- if ($entity->isNew()) {
- form_set_value($form['id'], $form_state['values']['theme'] . '.' . $form_state['values']['machine_name'], $form_state);
- }
- if (!empty($form['machine_name']['#disabled'])) {
- // Get machine name from original value (without prepended theme name).
- $config_id = explode('.', $form_state['values']['machine_name']);
- $form_state['values']['machine_name'] = array_pop($config_id);
- }
// Remove empty lines from the role visibility list.
$form_state['values']['visibility']['role']['roles'] = array_filter($form_state['values']['visibility']['role']['roles']);
// The Block Entity form puts all block plugin form elements in the
@@ -311,7 +298,7 @@ class BlockFormController extends EntityFormController {
'values' => &$form_state['values']['settings']
);
// Call the plugin validate handler.
- $entity->getPlugin()->validateConfigurationForm($form, $settings);
+ $this->entity->getPlugin()->validateConfigurationForm($form, $settings);
}
/**
diff --git a/core/modules/block/lib/Drupal/block/Entity/Block.php b/core/modules/block/lib/Drupal/block/Entity/Block.php
index 7f5c895a178..67d10e41008 100644
--- a/core/modules/block/lib/Drupal/block/Entity/Block.php
+++ b/core/modules/block/lib/Drupal/block/Entity/Block.php
@@ -125,24 +125,13 @@ class Block extends ConfigEntityBase implements BlockInterface {
return $settings['label'];
}
- /**
- * {@inheritdoc}
- */
- public function get($property_name) {
- // The theme is stored in the entity ID.
- $value = parent::get($property_name);
- if ($property_name == 'theme' && !$value) {
- list($value) = explode('.', $this->id());
- }
- return $value;
- }
-
/**
* Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::getExportProperties();
*/
public function getExportProperties() {
$properties = parent::getExportProperties();
$names = array(
+ 'theme',
'region',
'weight',
'plugin',
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php
index 3621f26fc0b..52120f14da7 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php
@@ -48,13 +48,13 @@ class BlockHookOperationTest extends WebTestBase {
public function testBlockOperationAlter() {
// Add a test block, any block will do.
// Set the machine name so the test_operation link can be built later.
- $block_machine_name = Unicode::strtolower($this->randomName(16));
- $this->drupalPlaceBlock('system_powered_by_block', array('machine_name' => $block_machine_name));
+ $block_id = Unicode::strtolower($this->randomName(16));
+ $this->drupalPlaceBlock('system_powered_by_block', array('id' => $block_id));
// Get the Block listing.
$this->drupalGet('admin/structure/block');
- $test_operation_link = 'admin/structure/block/manage/stark.' . $block_machine_name . '/test_operation';
+ $test_operation_link = 'admin/structure/block/manage/' . $block_id . '/test_operation';
// Test if the test_operation link is on the page.
$this->assertLinkByHref($test_operation_link);
}
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php
index c719fbecc37..de18e91f6f1 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php
@@ -40,7 +40,7 @@ class BlockHtmlIdTest extends WebTestBase {
// Enable our test blocks.
$this->drupalPlaceBlock('system_menu_block:tools');
- $this->drupalPlaceBlock('test_html_id', array('machine_name' => 'test_id_block'));
+ $this->drupalPlaceBlock('test_html_id', array('id' => 'test_id_block'));
}
/**
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php
index 915e4bb2cf4..2e4a4c6e5b6 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php
@@ -62,7 +62,7 @@ class BlockLanguageTest extends WebTestBase {
// Enable a standard block and set the visibility setting for one language.
$edit = array(
'visibility[language][langcodes][en]' => TRUE,
- 'machine_name' => strtolower($this->randomName(8)),
+ 'id' => strtolower($this->randomName(8)),
'region' => 'sidebar_first',
);
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme, $edit, t('Save block'));
@@ -99,7 +99,6 @@ class BlockLanguageTest extends WebTestBase {
),
),
),
- 'machine_name' => 'language_block_test',
);
$block = $this->drupalPlaceBlock('system_powered_by_block', $edit);
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php
index f92e8500d76..da6202e9f58 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php
@@ -45,17 +45,17 @@ class BlockRenderOrderTest extends WebTestBase {
// Enable test blocks and place them in the same region.
$region = 'header';
$test_blocks = array(
- 'stark.powered' => array(
+ 'stark_powered' => array(
'weight' => '-3',
- 'machine_name' => 'powered',
+ 'id' => 'stark_powered',
),
- 'stark.by' => array(
+ 'stark_by' => array(
'weight' => '3',
- 'machine_name' => 'by',
+ 'id' => 'stark_by',
),
- 'stark.drupal' => array(
+ 'stark_drupal' => array(
'weight' => '3',
- 'machine_name' => 'drupal',
+ 'id' => 'stark_drupal',
),
);
@@ -65,7 +65,7 @@ class BlockRenderOrderTest extends WebTestBase {
'label' => 'Test Block',
'region' => $region,
'weight' => $test_block['weight'],
- 'machine_name' => $test_block['machine_name'],
+ 'id' => $test_block['id'],
));
}
@@ -74,14 +74,13 @@ class BlockRenderOrderTest extends WebTestBase {
$controller = $this->container->get('entity.manager')->getStorageController('block');
foreach ($controller->loadMultiple() as $return_block) {
- $settings = $return_block->get('settings');
$id = $return_block->get('id');
if ($return_block_weight = $return_block->get('weight')) {
$this->assertTrue($test_blocks[$id]['weight'] == $return_block_weight, 'Block weight is set as "' . $return_block_weight . '" for ' . $id . ' block.');
- $position[$id] = strpos($test_content, 'block-' . $test_blocks[$id]['machine_name']);
+ $position[$id] = strpos($test_content, drupal_html_class('block-' . $test_blocks[$id]['id']));
}
}
- $this->assertTrue($position['stark.powered'] < $position['stark.by'], 'Blocks with different weight are rendered in the correct order.');
- $this->assertTrue($position['stark.drupal'] < $position['stark.by'], 'Blocks with identical weight are rendered in reverse alphabetical order.');
+ $this->assertTrue($position['stark_powered'] < $position['stark_by'], 'Blocks with different weight are rendered in the correct order.');
+ $this->assertTrue($position['stark_drupal'] < $position['stark_by'], 'Blocks with identical weight are rendered in reverse alphabetical order.');
}
}
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php
index d79d8435ca1..82827abd8b1 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php
@@ -76,7 +76,8 @@ class BlockStorageUnitTest extends DrupalUnitTestBase {
// Create a block with only required values.
$entity = $this->controller->create(array(
- 'id' => 'stark.test_block',
+ 'id' => 'test_block',
+ 'theme' => 'stark',
'plugin' => 'test_html_id',
));
$entity->save();
@@ -84,16 +85,17 @@ class BlockStorageUnitTest extends DrupalUnitTestBase {
$this->assertTrue($entity instanceof Block, 'The newly created entity is a Block.');
// Verify all of the block properties.
- $actual_properties = \Drupal::config('block.block.stark.test_block')->get();
+ $actual_properties = \Drupal::config('block.block.test_block')->get();
$this->assertTrue(!empty($actual_properties['uuid']), 'The block UUID is set.');
unset($actual_properties['uuid']);
// Ensure that default values are filled in.
$expected_properties = array(
- 'id' => 'stark.test_block',
+ 'id' => 'test_block',
'weight' => NULL,
'status' => TRUE,
'langcode' => language_default()->id,
+ 'theme' => 'stark',
'region' => -1,
'plugin' => 'test_html_id',
'settings' => array(
@@ -113,7 +115,7 @@ class BlockStorageUnitTest extends DrupalUnitTestBase {
* Tests the rendering of blocks.
*/
protected function loadTests() {
- $entity = $this->controller->load('stark.test_block');
+ $entity = $this->controller->load('test_block');
$this->assertTrue($entity instanceof Block, 'The loaded entity is a Block.');
@@ -129,7 +131,7 @@ class BlockStorageUnitTest extends DrupalUnitTestBase {
*/
protected function renderTests() {
// Test the rendering of a block.
- $entity = entity_load('block', 'stark.test_block');
+ $entity = entity_load('block', 'test_block');
$output = entity_view($entity, 'block');
$expected = array();
$expected[] = '
';
@@ -149,7 +151,8 @@ class BlockStorageUnitTest extends DrupalUnitTestBase {
// Test the rendering of a block with a given title.
$entity = $this->controller->create(array(
- 'id' => 'stark.test_block2',
+ 'id' => 'test_block2',
+ 'theme' => 'stark',
'plugin' => 'test_html_id',
'settings' => array(
'label' => 'Powered by Bananas',
@@ -178,7 +181,7 @@ class BlockStorageUnitTest extends DrupalUnitTestBase {
* Tests the deleting of blocks.
*/
protected function deleteTests() {
- $entity = $this->controller->load('stark.test_block');
+ $entity = $this->controller->load('test_block');
// Ensure that the storage isn't currently empty.
$config_storage = $this->container->get('config.storage');
@@ -205,7 +208,7 @@ class BlockStorageUnitTest extends DrupalUnitTestBase {
$entities = $this->controller->loadMultiple();
$entity = reset($entities);
- $this->assertEqual($entity->id(), 'stark.test_block', 'The default test block was loaded.');
+ $this->assertEqual($entity->id(), 'test_block', 'The default test block was loaded.');
}
}
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php
index 8289eb4ed1d..6d962edfbf9 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php
@@ -40,7 +40,7 @@ class BlockTemplateSuggestionsUnitTest extends WebTestBase {
$block = entity_create('block', array(
'plugin' => 'system_menu_block:admin',
'region' => 'footer',
- 'id' => \Drupal::config('system.theme')->get('default') . '.machinename',
+ 'id' => 'machinename',
));
$variables = array();
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
index fe1dca18eb1..27bf1b28d30 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
@@ -32,7 +32,7 @@ class BlockTest extends BlockTestBase {
// Enable a standard block.
$default_theme = \Drupal::config('system.theme')->get('default');
$edit = array(
- 'machine_name' => strtolower($this->randomName(8)),
+ 'id' => strtolower($this->randomName(8)),
'region' => 'sidebar_first',
'settings[label]' => $title,
);
@@ -73,7 +73,7 @@ class BlockTest extends BlockTestBase {
// Enable a standard block.
$default_theme = \Drupal::config('system.theme')->get('default');
$edit = array(
- 'machine_name' => strtolower($this->randomName(8)),
+ 'id' => strtolower($this->randomName(8)),
'region' => 'sidebar_first',
'settings[label]' => $title,
'visibility[path][visibility]' => BLOCK_VISIBILITY_LISTED,
@@ -103,15 +103,14 @@ class BlockTest extends BlockTestBase {
$block = array();
$block['id'] = 'system_powered_by_block';
$block['settings[label]'] = $this->randomName(8);
- $block['machine_name'] = strtolower($this->randomName(8));
$block['theme'] = \Drupal::config('system.theme')->get('default');
$block['region'] = 'header';
// Set block title to confirm that interface works and override any custom titles.
- $this->drupalPostForm('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], array('settings[label]' => $block['settings[label]'], 'machine_name' => $block['machine_name'], 'region' => $block['region']), t('Save block'));
+ $this->drupalPostForm('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], array('settings[label]' => $block['settings[label]'], 'id' => $block['id'], 'region' => $block['region']), t('Save block'));
$this->assertText(t('The block configuration has been saved.'), 'Block title set.');
// Check to see if the block was created by checking its configuration.
- $instance = entity_load('block', $block['theme'] . '.' . $block['machine_name']);
+ $instance = entity_load('block', $block['id']);
$this->assertEqual($instance->label(), $block['settings[label]'], 'Stored block title found.');
@@ -122,7 +121,7 @@ class BlockTest extends BlockTestBase {
// Set the block to the disabled region.
$edit = array();
- $edit['blocks[' . $block['theme'] . '.' . $block['machine_name'] . '][region]'] = -1;
+ $edit['blocks[' . $block['id'] . '][region]'] = -1;
$this->drupalPostForm('admin/structure/block', $edit, t('Save blocks'));
// Confirm that the block is now listed as disabled.
@@ -133,11 +132,11 @@ class BlockTest extends BlockTestBase {
$this->assertNoText(t($block['settings[label]']));
// Check for
if the machine name
// is my_block_instance_name.
- $xpath = $this->buildXPathQuery('//div[@id=:id]/*', array(':id' => 'block-' . strtr(strtolower($block['machine_name']), '-', '_')));
+ $xpath = $this->buildXPathQuery('//div[@id=:id]/*', array(':id' => 'block-' . str_replace('_', '-', strtolower($block['id']))));
$this->assertNoFieldByXPath($xpath, FALSE, 'Block found in no regions.');
// Test deleting the block from the edit form.
- $this->drupalGet('admin/structure/block/manage/' . $block['theme'] . '.' . $block['machine_name']);
+ $this->drupalGet('admin/structure/block/manage/' . $block['id']);
$this->drupalPostForm(NULL, array(), t('Delete'));
$this->assertRaw(t('Are you sure you want to delete the block %name?', array('%name' => $block['settings[label]'])));
$this->drupalPostForm(NULL, array(), t('Delete'));
@@ -154,17 +153,17 @@ class BlockTest extends BlockTestBase {
foreach (array('bartik', 'stark', 'seven') as $theme) {
// Select the 'Powered by Drupal' block to be placed.
$block = array();
- $block['machine_name'] = strtolower($this->randomName(8));
+ $block['id'] = strtolower($this->randomName());
$block['theme'] = $theme;
$block['region'] = 'content';
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block', $block, t('Save block'));
$this->assertText(t('The block configuration has been saved.'));
- $this->assertUrl('admin/structure/block/list/' . $theme . '?block-placement=' . drupal_html_class($theme . ':' . $block['machine_name']));
+ $this->assertUrl('admin/structure/block/list/' . $theme . '?block-placement=' . drupal_html_class($block['id']));
// Set the default theme and ensure the block is placed.
$theme_settings->set('default', $theme)->save();
$this->drupalGet('');
- $elements = $this->xpath('//div[@id = :id]', array(':id' => drupal_html_id('block-' . $block['machine_name'])));
+ $elements = $this->xpath('//div[@id = :id]', array(':id' => drupal_html_id('block-' . $block['id'])));
$this->assertTrue(!empty($elements), 'The block was found.');
}
}
@@ -176,11 +175,11 @@ class BlockTest extends BlockTestBase {
$block_name = 'system_powered_by_block';
// Create a random title for the block.
$title = $this->randomName(8);
- $machine_name = strtolower($this->randomName(8));
+ $id = strtolower($this->randomName(8));
// Enable a standard block.
$default_theme = \Drupal::config('system.theme')->get('default') ?: 'stark';
$edit = array(
- 'machine_name' => $machine_name,
+ 'id' => $id,
'region' => 'sidebar_first',
'settings[label]' => $title,
);
@@ -193,7 +192,7 @@ class BlockTest extends BlockTestBase {
$edit = array(
'settings[label_display]' => FALSE,
);
- $this->drupalPostForm('admin/structure/block/manage/' . $default_theme . '.' . $machine_name, $edit, t('Save block'));
+ $this->drupalPostForm('admin/structure/block/manage/' . $id, $edit, t('Save block'));
$this->assertText('The block configuration has been saved.', 'Block was saved');
$this->drupalGet('user');
@@ -216,7 +215,7 @@ class BlockTest extends BlockTestBase {
// Set the created block to a specific region.
$block += array('theme' => \Drupal::config('system.theme')->get('default'));
$edit = array();
- $edit['blocks[' . $block['theme'] . '.' . $block['machine_name'] . '][region]'] = $region;
+ $edit['blocks[' . $block['id'] . '][region]'] = $region;
$this->drupalPostForm('admin/structure/block', $edit, t('Save blocks'));
// Confirm that the block was moved to the proper region.
@@ -229,7 +228,7 @@ class BlockTest extends BlockTestBase {
// Confirm that the custom block was found at the proper region.
$xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', array(
':region-class' => 'region region-' . drupal_html_class($region),
- ':block-id' => 'block-' . strtr(strtolower($block['machine_name']), '-', '_'),
+ ':block-id' => 'block-' . str_replace('_', '-', strtolower($block['id'])),
));
$this->assertFieldByXPath($xpath, NULL, t('Block found in %region_name region.', array('%region_name' => drupal_html_class($region))));
}
@@ -247,7 +246,6 @@ class BlockTest extends BlockTestBase {
// Add a test block.
$block = array();
$block['id'] = 'test_cache';
- $block['machine_name'] = strtolower($this->randomName(8));
$block['theme'] = \Drupal::config('system.theme')->get('default');
$block['region'] = 'header';
$block = $this->drupalPlaceBlock('test_cache', array('region' => 'header'));
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php b/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php
index 117e7c140d2..3dbbf90eca0 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php
@@ -66,40 +66,10 @@ abstract class BlockTestBase extends WebTestBase {
'sidebar_second',
'footer',
);
-
+ $block_storage = $this->container->get('entity.manager')->getStorageController('block');
+ $blocks = $block_storage->loadByProperties(array('theme' => \Drupal::config('system.theme')->get('default')));
+ foreach ($blocks as $block) {
+ $block->delete();
+ }
}
-
- /**
- * Moves a block to a given region via the UI and confirms the result.
- *
- * @param array $block
- * An array of information about the block, including the following keys:
- * - module: The module providing the block.
- * - title: The title of the block.
- * - delta: The block's delta key.
- * @param string $region
- * The machine name of the theme region to move the block to, for example
- * 'header' or 'sidebar_first'.
- */
- function moveBlockToRegion(array $block, $region) {
- // Set the created block to a specific region.
- $edit = array();
- $edit['blocks[0][region]'] = $region;
- $this->drupalPostForm('admin/structure/block', $edit, t('Save blocks'));
-
- // Confirm that the block was moved to the proper region.
- $this->assertText(t('The block settings have been updated.'), format_string('Block successfully moved to %region_name region.', array( '%region_name' => $region)));
-
- // Confirm that the block is being displayed.
- $this->drupalGet('');
- $this->assertText(t($block['title']), 'Block successfully being displayed on the page.');
-
- // Confirm that the custom block was found at the proper region.
- $xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', array(
- ':region-class' => 'region region-' . drupal_html_class($region),
- ':block-id' => 'block-' . strtr(strtolower($block['machine_name']), '-', '_'),
- ));
- $this->assertFieldByXPath($xpath, NULL, t('Block found in %region_name region.', array('%region_name' => drupal_html_class($region))));
- }
-
}
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php
index da7648478d5..05921ed2f68 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php
@@ -51,14 +51,14 @@ class BlockUiTest extends WebTestBase {
'label' => 'Tools',
'tr' => '5',
'plugin_id' => 'system_menu_block:tools',
- 'settings' => array('region' => 'sidebar_second', 'machine_name' => 'tools'),
+ 'settings' => array('region' => 'sidebar_second', 'id' => 'tools'),
'test_weight' => '-1',
),
array(
'label' => 'Powered by Drupal',
'tr' => '12',
'plugin_id' => 'system_powered_by_block',
- 'settings' => array('region' => 'footer', 'machine_name' => 'powered'),
+ 'settings' => array('region' => 'footer', 'id' => 'powered'),
'test_weight' => '0',
),
);
@@ -92,24 +92,24 @@ class BlockUiTest extends WebTestBase {
$element = $this->xpath('//*[@id="blocks"]/tbody/tr[' . $values['tr'] . ']/td[1]/text()');
$this->assertTrue((string)$element[0] == $values['label'], 'The "' . $values['label'] . '" block title is set inside the ' . $values['settings']['region'] . ' region.');
// Look for a test block region select form element.
- $this->assertField('blocks[stark.' . $values['settings']['machine_name'] . '][region]', 'The block "' . $values['label'] . '" has a region assignment field.');
+ $this->assertField('blocks[' . $values['settings']['id'] . '][region]', 'The block "' . $values['label'] . '" has a region assignment field.');
// Move the test block to the header region.
- $edit['blocks[stark.' . $values['settings']['machine_name'] . '][region]'] = 'header';
+ $edit['blocks[' . $values['settings']['id'] . '][region]'] = 'header';
// Look for a test block weight select form element.
- $this->assertField('blocks[stark.' . $values['settings']['machine_name'] . '][weight]', 'The block "' . $values['label'] . '" has a weight assignment field.');
+ $this->assertField('blocks[' . $values['settings']['id'] . '][weight]', 'The block "' . $values['label'] . '" has a weight assignment field.');
// Change the test block's weight.
- $edit['blocks[stark.' . $values['settings']['machine_name'] . '][weight]'] = $values['test_weight'];
+ $edit['blocks[' . $values['settings']['id'] . '][weight]'] = $values['test_weight'];
}
$this->drupalPostForm('admin/structure/block', $edit, t('Save blocks'));
foreach ($this->testBlocks as $values) {
// Check if the region and weight settings changes have persisted.
$this->assertOptionSelected(
- 'edit-blocks-stark' . $values['settings']['machine_name'] . '-region',
+ 'edit-blocks-' . $values['settings']['id'] . '-region',
'header',
'The block "' . $values['label'] . '" has the correct region assignment (header).'
);
$this->assertOptionSelected(
- 'edit-blocks-stark' . $values['settings']['machine_name'] . '-weight',
+ 'edit-blocks-' . $values['settings']['id'] . '-weight',
$values['test_weight'],
'The block "' . $values['label'] . '" has the correct weight assignment (' . $values['test_weight'] . ').'
);
@@ -146,17 +146,17 @@ class BlockUiTest extends WebTestBase {
public function testMachineNameSuggestion() {
$url = 'admin/structure/block/add/test_block_instantiation/stark';
$this->drupalGet($url);
- $this->assertFieldByName('machine_name', 'displaymessage', 'Block form uses raw machine name suggestion when no instance already exists.');
+ $this->assertFieldByName('id', 'displaymessage', 'Block form uses raw machine name suggestion when no instance already exists.');
$this->drupalPostForm($url, array(), 'Save block');
// Now, check to make sure the form starts by autoincrementing correctly.
$this->drupalGet($url);
- $this->assertFieldByName('machine_name', 'displaymessage_2', 'Block form appends _2 to plugin-suggested machine name when an instance already exists.');
+ $this->assertFieldByName('id', 'displaymessage_2', 'Block form appends _2 to plugin-suggested machine name when an instance already exists.');
$this->drupalPostForm($url, array(), 'Save block');
// And verify that it continues working beyond just the first two.
$this->drupalGet($url);
- $this->assertFieldByName('machine_name', 'displaymessage_3', 'Block form appends _3 to plugin-suggested machine name when two instances already exist.');
+ $this->assertFieldByName('id', 'displaymessage_3', 'Block form appends _3 to plugin-suggested machine name when two instances already exist.');
}
}
diff --git a/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php b/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php
index 00fccc31bcf..b3bf5b9b754 100644
--- a/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php
@@ -36,16 +36,21 @@ class NewDefaultThemeBlocksTest extends WebTestBase {
$default_theme = \Drupal::config('system.theme')->get('default');
// Add several block instances.
- $this->adminUser = $this->drupalCreateUser(array('administer blocks'));
- $this->drupalLogin($this->adminUser);
+ $this->drupalLogin($this->drupalCreateUser(array('administer blocks')));
// Add two instances of the user login block.
- $this->drupalPlaceBlock('user_login_block');
- $this->drupalPlaceBlock('user_login_block');
+ $this->drupalPlaceBlock('user_login_block', array(
+ 'id' => $default_theme . '_' . strtolower($this->randomName(8)),
+ ));
+ $this->drupalPlaceBlock('user_login_block', array(
+ 'id' => $default_theme . '_' . strtolower($this->randomName(8)),
+ ));
// Add an instance of a different block.
- $this->drupalPlaceBlock('system_powered_by_block');
- $this->drupalLogout($this->adminUser);
+ $this->drupalPlaceBlock('system_powered_by_block', array(
+ 'id' => $default_theme . '_' . strtolower($this->randomName(8)),
+ ));
+ $this->drupalLogout();
// Enable a different theme.
$new_theme = 'bartik';
@@ -56,30 +61,18 @@ class NewDefaultThemeBlocksTest extends WebTestBase {
->save();
// Ensure that the new theme has all the blocks as the previous default.
- // @todo Replace the string manipulation below once the configuration
- // system provides a method for extracting an ID in a given namespace.
- $default_prefix = "block.block.$default_theme";
- $new_prefix = "block.block.$new_theme";
- $default_block_names = config_get_storage_names_with_prefix($default_prefix);
- $new_blocks = array_flip(config_get_storage_names_with_prefix($new_prefix));
+ $default_block_names = $this->container->get('entity.query')->get('block')
+ ->condition('theme', $default_theme)
+ ->execute();
+ $new_blocks = $this->container->get('entity.query')->get('block')
+ ->condition('theme', $new_theme)
+ ->execute();
$this->assertTrue(count($default_block_names) == count($new_blocks), 'The new default theme has the same number of blocks as the previous theme.');
foreach ($default_block_names as $default_block_name) {
- // Make sure the configuration object name is in the expected format.
- if (strpos($default_block_name, $default_prefix) === 0) {
- // Remove the matching block from the list of blocks in the new theme.
- // E.g., if the old theme has block.block.stark.admin,
- // unset block.block.bartik.admin.
- $id = substr($default_block_name, (strlen($default_prefix) + 1));
- unset($new_blocks[$new_prefix . '.' . $id]);
- }
- else {
- $this->fail(format_string(
- '%block is not an expected block instance name.',
- array(
- '%block' => $default_block_name,
- )
- ));
- }
+ // Remove the matching block from the list of blocks in the new theme.
+ // E.g., if the old theme has block.block.stark_admin,
+ // unset block.block.bartik_admin.
+ unset($new_blocks[str_replace($default_theme . '_', $new_theme . '_', $default_block_name)]);
}
$this->assertTrue(empty($new_blocks), 'The new theme has exactly the same blocks as the previous default theme.');
}
diff --git a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php
index a2e0a55b302..d759c5712e8 100644
--- a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php
@@ -184,11 +184,11 @@ class DisplayBlockTest extends ViewTestBase {
$this->assertTrue(empty($elements), 'The label field is not found for Views blocks.');
// Test that that machine name field is hidden from display and has been
// saved as expected from the default value.
- $this->assertNoFieldById('edit-machine-name', 'stark.views_block__test_view_block_1', 'The machine name is hidden on the views block form.');
+ $this->assertNoFieldById('edit-machine-name', 'views_block__test_view_block_1', 'The machine name is hidden on the views block form.');
// Save the block.
$this->drupalPostForm(NULL, array(), t('Save block'));
$storage = $this->container->get('entity.manager')->getStorageController('block');
- $block = $storage->load('stark.views_block__test_view_block_block_1');
+ $block = $storage->load('views_block__test_view_block_block_1');
// This will only return a result if our new block has been created with the
// expected machine name.
$this->assertTrue(!empty($block), 'The expected block was loaded.');
@@ -196,7 +196,7 @@ class DisplayBlockTest extends ViewTestBase {
for ($i = 2; $i <= 3; $i++) {
// Place the same block again and make sure we have a new ID.
$this->drupalPostForm('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, array(), t('Save block'));
- $block = $storage->load('stark.views_block__test_view_block_block_1_' . $i);
+ $block = $storage->load('views_block__test_view_block_block_1_' . $i);
// This will only return a result if our new block has been created with the
// expected machine name.
$this->assertTrue(!empty($block), 'The expected block was loaded.');
@@ -209,14 +209,14 @@ class DisplayBlockTest extends ViewTestBase {
$this->drupalPostForm('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, $edit, t('Save block'));
- $block = $storage->load('stark.views_block__test_view_block_block_1_4');
+ $block = $storage->load('views_block__test_view_block_block_1_4');
$config = $block->getPlugin()->getConfiguration();
$this->assertEqual(10, $config['items_per_page'], "'Items per page' is properly saved.");
$edit['settings[override][items_per_page]'] = 5;
- $this->drupalPostForm('admin/structure/block/manage/stark.views_block__test_view_block_block_1_4', $edit, t('Save block'));
+ $this->drupalPostForm('admin/structure/block/manage/views_block__test_view_block_block_1_4', $edit, t('Save block'));
- $block = $storage->load('stark.views_block__test_view_block_block_1_4');
+ $block = $storage->load('views_block__test_view_block_block_1_4');
$config = $block->getPlugin()->getConfiguration();
$this->assertEqual(5, $config['items_per_page'], "'Items per page' is properly saved.");
diff --git a/core/modules/block/tests/modules/block_test/config/block.block.stark.test_block.yml b/core/modules/block/tests/modules/block_test/config/block.block.stark.test_block.yml
index e8b5ade35db..4b68aca9886 100644
--- a/core/modules/block/tests/modules/block_test/config/block.block.stark.test_block.yml
+++ b/core/modules/block/tests/modules/block_test/config/block.block.stark.test_block.yml
@@ -1,4 +1,5 @@
-id: stark.test_block
+id: test_block
+theme: stark
weight: ''
status: '1'
langcode: en
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php
index 3d4e25100b5..4613f431172 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php
@@ -43,7 +43,7 @@ class LanguageSwitchingTest extends WebTestBase {
*/
function testLanguageBlock() {
// Enable the language switching block.
- $block = $this->drupalPlaceBlock('language_block:' . Language::TYPE_INTERFACE, array('machine_name' => 'test_language_block'));
+ $block = $this->drupalPlaceBlock('language_block:' . Language::TYPE_INTERFACE, array('id' => 'test_language_block'));
// Add language.
$edit = array(
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
index e87a55014e5..9bee36b3142 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
@@ -408,7 +408,7 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
$this->drupalGet('admin/config/regional/language/detection');
// Enable the language switcher block.
- $this->drupalPlaceBlock('language_block:' . Language::TYPE_INTERFACE, array('machine_name' => 'test_language_block'));
+ $this->drupalPlaceBlock('language_block:' . Language::TYPE_INTERFACE, array('id' => 'test_language_block'));
// Access the front page without specifying any valid URL language prefix
// and having as browser language preference a non-default language.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
index a63bcf8e2c6..70598eec607 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
@@ -61,7 +61,7 @@ class NodeBlockFunctionalTest extends NodeTestBase {
));
// Enable the recent content block with two items.
- $block = $this->drupalPlaceBlock('node_recent_block', array('machine_name' => 'test_block', 'block_count' => 2));
+ $block = $this->drupalPlaceBlock('node_recent_block', array('id' => 'test_block', 'block_count' => 2));
// Test that block is not visible without nodes.
$this->drupalGet('');
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeSyndicateBlockTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeSyndicateBlockTest.php
index 887b7eab51b..06a618f9826 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeSyndicateBlockTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeSyndicateBlockTest.php
@@ -40,7 +40,7 @@ class NodeSyndicateBlockTest extends NodeTestBase {
*/
public function testSyndicateBlock() {
// Place the "Syndicate" block and confirm that it is rendered.
- $this->drupalPlaceBlock('node_syndicate_block', array('machine_name' => 'test_syndicate_block'));
+ $this->drupalPlaceBlock('node_syndicate_block', array('id' => 'test_syndicate_block'));
$this->drupalGet('');
$this->assertFieldByXPath('//div[@id="block-test-syndicate-block"]/*', NULL, 'Syndicate block found.');
}
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index a307e32af87..3da3e93f36a 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -353,7 +353,7 @@ abstract class WebTestBase extends TestBase {
* @endcode
* The following defaults are provided:
* - label: Random string.
- * - machine_name: Random string.
+ * - id: Random string.
* - region: 'sidebar_first'.
* - theme: The default theme.
* - visibility: Empty array.
@@ -368,20 +368,18 @@ abstract class WebTestBase extends TestBase {
$settings += array(
'plugin' => $plugin_id,
'region' => 'sidebar_first',
- 'machine_name' => strtolower($this->randomName(8)),
+ 'id' => strtolower($this->randomName(8)),
'theme' => \Drupal::config('system.theme')->get('default'),
'label' => $this->randomName(8),
'visibility' => array(),
'weight' => 0,
);
- foreach (array('region', 'machine_name', 'theme', 'plugin', 'visibility', 'weight') as $key) {
+ foreach (array('region', 'id', 'theme', 'plugin', 'visibility', 'weight') as $key) {
$values[$key] = $settings[$key];
// Remove extra values that do not belong in the settings array.
unset($settings[$key]);
}
$values['settings'] = $settings;
- // Build the ID out of the theme and machine_name.
- $values['id'] = $values['theme'] . '.' . $values['machine_name'];
$block = entity_create('block', $values);
$block->save();
return $block;
diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
index 31bc82b9c0a..4c03fa0f8f8 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
@@ -43,14 +43,12 @@ class BreadcrumbTest extends MenuTestBase {
// This test puts menu links in the Tools menu and then tests for their
// presence on the page, so we need to ensure that the Tools block will be
- // displayed in the default theme and admin theme.
- $settings = array(
- 'machine_name' => 'system_menu_tools',
+ // displayed in the admin theme.
+ $this->drupalPlaceBlock('system_menu_block:tools', array(
+ 'machine' => 'system_menu_tools',
'region' => 'content',
- );
- $this->drupalPlaceBlock('system_menu_block:tools', $settings);
- $settings['theme'] = \Drupal::config('system.theme')->get('admin');
- $this->drupalPlaceBlock('system_menu_block:tools', $settings);
+ 'theme' => \Drupal::config('system.theme')->get('admin'),
+ ));
}
/**
@@ -279,7 +277,7 @@ class BreadcrumbTest extends MenuTestBase {
// ('taxonomy/term/%') should never be translated and appear in any menu
// other than the breadcrumb trail.
$elements = $this->xpath('//div[@id=:menu]/descendant::a[@href=:href]', array(
- ':menu' => 'block-system-menu-tools',
+ ':menu' => 'block-bartik-tools',
':href' => url($link['link_path']),
));
$this->assertTrue(count($elements) == 1, "Link to {$link['link_path']} appears only once.");
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php b/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php
index 915e3e8368b..383ace1db44 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php
@@ -54,7 +54,7 @@ class AccessDeniedTest extends WebTestBase {
$this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
// Enable the user login block.
- $this->drupalPlaceBlock('user_login_block', array('machine_name' => 'login'));
+ $this->drupalPlaceBlock('user_login_block', array('id' => 'login'));
// Log out and check that the user login block is shown on custom 403 pages.
$this->drupalLogout();
@@ -82,7 +82,7 @@ class AccessDeniedTest extends WebTestBase {
$edit = array(
'region' => -1,
);
- $this->drupalPostForm('admin/structure/block/manage/stark.login', $edit, t('Save block'));
+ $this->drupalPostForm('admin/structure/block/manage/login', $edit, t('Save block'));
// Check that we can log in from the 403 page.
$this->drupalLogout();
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php
index 79ff2a9b7b7..e1bb4b1656b 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php
@@ -43,7 +43,7 @@ class BlockUpgradePathTest extends UpgradePathTestBase {
// Confirm that the custom block has been created, and title matches input.
$settings = array(
'settings[label]' => $this->randomName(255),
- 'machine_name' => strtolower($this->randomName(8)),
+ 'id' => strtolower($this->randomName(8)),
'region' => 'sidebar_first',
);
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block/' . \Drupal::config('system.theme')->get('default'), $settings, t('Save block'));
@@ -52,7 +52,7 @@ class BlockUpgradePathTest extends UpgradePathTestBase {
// Try to add a block with a title over 255 characters.
$settings = array(
'settings[label]' => $this->randomName(256),
- 'machine_name' => strtolower($this->randomName(8)),
+ 'id' => strtolower($this->randomName(8)),
'region' => 'sidebar_first',
);
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block/' . \Drupal::config('system.theme')->get('default'), $settings, t('Save block'));
diff --git a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php
index 32f861bf744..3f3fe30e69c 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php
@@ -9,7 +9,7 @@ namespace Drupal\views\Plugin\Block;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
-use Drupal\Core\Entity\EntityStorageControllerInterface;
+use Drupal\Core\Config\Entity\Query\Query;
use Drupal\Component\Utility\Xss;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -84,36 +84,6 @@ class ViewsBlock extends ViewsBlockBase {
}
}
- /**
- * Generates a views block instance ID.
- *
- * @param \Drupal\Core\Entity\EntityStorageControllerInterface $manager
- * The block storage controller.
- *
- * @return string
- * The new block instance ID.
- */
- public function generateBlockInstanceID(EntityStorageControllerInterface $manager) {
- $original_id = 'views_block__' . $this->view->storage->id() . '_' . $this->view->current_display;
-
- // Get an array of block IDs without the theme prefix.
- $block_ids = array_map(function ($block_id) {
- $parts = explode('.', $block_id);
- return end($parts);
- }, array_keys($manager->loadMultiple()));
-
- // Iterate through potential IDs until we get a new one. E.g.
- // 'views_block__MYVIEW_PAGE_1_2'
- $count = 1;
- $id = $original_id;
- while (in_array($id, $block_ids)) {
- $id = $original_id . '_' . ++$count;
- }
-
- return $id;
- }
-
-
/**
* {@inheritdoc}
*/
diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php
index 05b70354596..33e0b727d0e 100644
--- a/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php
@@ -120,11 +120,11 @@ class ExposedFormTest extends ViewTestBase {
$this->drupalGet('test_exposed_block');
// Test there is an exposed form in a block.
- $xpath = $this->buildXPathQuery('//div[@id=:id]/div/form/@id', array(':id' => 'block-' . $block->get('machine_name')));
+ $xpath = $this->buildXPathQuery('//div[@id=:id]/div/form/@id', array(':id' => drupal_html_id('block-' . $block->id())));
$this->assertFieldByXpath($xpath, $this->getExpectedExposedFormId($view), 'Expected form found in views block.');
// Test there is not an exposed form in the view page content area.
- $xpath = $this->buildXPathQuery('//div[@class="view-content"]/form/@id', array(':id' => 'block-' . $block->get('machine_name')));
+ $xpath = $this->buildXPathQuery('//div[@class="view-content"]/form/@id', array(':id' => drupal_html_id('block-' . $block->id())));
$this->assertNoFieldByXpath($xpath, $this->getExpectedExposedFormId($view), 'No exposed form found in views content region.');
// Test there is only one views exposed form on the page.
diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php
index db703fe93fc..86706b504f3 100644
--- a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php
+++ b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php
@@ -268,9 +268,7 @@ abstract class ViewTestBase extends WebTestBase {
* The result from the xpath query.
*/
protected function findBlockInstance(Block $block) {
- $config_id = explode('.', $block->id());
- $machine_name = array_pop($config_id);
- return $this->xpath('//div[@id = :id]', array(':id' => 'block-' . $machine_name));
+ return $this->xpath('//div[@id = :id]', array(':id' => 'block-' . $block->id()));
}
/**
diff --git a/core/profiles/minimal/config/block.block.stark.admin.yml b/core/profiles/minimal/config/block.block.stark.admin.yml
index e22ff725c16..1c11ab59058 100644
--- a/core/profiles/minimal/config/block.block.stark.admin.yml
+++ b/core/profiles/minimal/config/block.block.stark.admin.yml
@@ -1,4 +1,5 @@
-id: stark.admin
+id: stark_admin
+theme: stark
weight: '1'
status: '1'
langcode: en
diff --git a/core/profiles/minimal/config/block.block.stark.login.yml b/core/profiles/minimal/config/block.block.stark.login.yml
index b15e39593c9..a727ff5ef00 100644
--- a/core/profiles/minimal/config/block.block.stark.login.yml
+++ b/core/profiles/minimal/config/block.block.stark.login.yml
@@ -1,4 +1,5 @@
-id: stark.login
+id: stark_login
+theme: stark
weight: '0'
status: '1'
langcode: en
diff --git a/core/profiles/minimal/config/block.block.stark.tools.yml b/core/profiles/minimal/config/block.block.stark.tools.yml
index c53d934abab..6073ede0aa2 100644
--- a/core/profiles/minimal/config/block.block.stark.tools.yml
+++ b/core/profiles/minimal/config/block.block.stark.tools.yml
@@ -1,4 +1,5 @@
-id: stark.tools
+id: stark_tools
+theme: stark
weight: '0'
status: '1'
langcode: en
diff --git a/core/profiles/standard/config/block.block.bartik.breadcrumbs.yml b/core/profiles/standard/config/block.block.bartik.breadcrumbs.yml
index b2d19c45686..c915c4690e5 100644
--- a/core/profiles/standard/config/block.block.bartik.breadcrumbs.yml
+++ b/core/profiles/standard/config/block.block.bartik.breadcrumbs.yml
@@ -1,4 +1,5 @@
-id: bartik.breadcrumbs
+id: bartik_breadcrumbs
+theme: bartik
uuid: a29e843f-d19c-4528-ab02-2fc335e12b1e
weight: '-5'
status: '0'
diff --git a/core/profiles/standard/config/block.block.bartik.content.yml b/core/profiles/standard/config/block.block.bartik.content.yml
index ae0fe804c6e..5b7187b0733 100644
--- a/core/profiles/standard/config/block.block.bartik.content.yml
+++ b/core/profiles/standard/config/block.block.bartik.content.yml
@@ -1,4 +1,5 @@
-id: bartik.content
+id: bartik_content
+theme: bartik
uuid: 2cab5a0c-de08-4b5c-9700-f0243a6fb000
weight: '0'
status: '1'
diff --git a/core/profiles/standard/config/block.block.bartik.footer.yml b/core/profiles/standard/config/block.block.bartik.footer.yml
index 8519cab3119..2ad2766bb54 100644
--- a/core/profiles/standard/config/block.block.bartik.footer.yml
+++ b/core/profiles/standard/config/block.block.bartik.footer.yml
@@ -1,4 +1,5 @@
-id: bartik.footer
+id: bartik_footer
+theme: bartik
uuid: a6c75fc2-5ca1-403e-ab37-557c7244e8c0
weight: '0'
status: '1'
diff --git a/core/profiles/standard/config/block.block.bartik.help.yml b/core/profiles/standard/config/block.block.bartik.help.yml
index 00c1176993e..c697560d648 100644
--- a/core/profiles/standard/config/block.block.bartik.help.yml
+++ b/core/profiles/standard/config/block.block.bartik.help.yml
@@ -1,4 +1,5 @@
-id: bartik.help
+id: bartik_help
+theme: bartik
uuid: 6ea8e05a-6793-4ecf-8801-015dc6e1013e
weight: '0'
status: '1'
diff --git a/core/profiles/standard/config/block.block.bartik.login.yml b/core/profiles/standard/config/block.block.bartik.login.yml
index 9a82618b338..e94f5623e6a 100644
--- a/core/profiles/standard/config/block.block.bartik.login.yml
+++ b/core/profiles/standard/config/block.block.bartik.login.yml
@@ -1,4 +1,5 @@
-id: bartik.login
+id: bartik_login
+theme: bartik
uuid: 961f4152-3e91-4c9f-9114-20a5375675d0
weight: '0'
status: '1'
diff --git a/core/profiles/standard/config/block.block.bartik.powered.yml b/core/profiles/standard/config/block.block.bartik.powered.yml
index 1dbe2db0cad..265f2716c33 100644
--- a/core/profiles/standard/config/block.block.bartik.powered.yml
+++ b/core/profiles/standard/config/block.block.bartik.powered.yml
@@ -1,4 +1,5 @@
-id: bartik.powered
+id: bartik_powered
+theme: bartik
uuid: 37cff101-27dc-478d-9d00-b58b9d884039
weight: '10'
status: '1'
diff --git a/core/profiles/standard/config/block.block.bartik.search.yml b/core/profiles/standard/config/block.block.bartik.search.yml
index 8d1f94bcd8f..d37e197281a 100644
--- a/core/profiles/standard/config/block.block.bartik.search.yml
+++ b/core/profiles/standard/config/block.block.bartik.search.yml
@@ -1,4 +1,5 @@
-id: bartik.search
+id: bartik_search
+theme: bartik
uuid: 51f70058-a370-4410-9000-a65488d00e6c
weight: '-1'
status: '1'
diff --git a/core/profiles/standard/config/block.block.bartik.tools.yml b/core/profiles/standard/config/block.block.bartik.tools.yml
index 0a9e6fafbaa..b94065195e9 100644
--- a/core/profiles/standard/config/block.block.bartik.tools.yml
+++ b/core/profiles/standard/config/block.block.bartik.tools.yml
@@ -1,4 +1,5 @@
-id: bartik.tools
+id: bartik_tools
+theme: bartik
uuid: 0dca3209-c6fa-4043-a407-7afb952cfc5e
weight: '0'
status: '1'
diff --git a/core/profiles/standard/config/block.block.seven.breadcrumbs.yml b/core/profiles/standard/config/block.block.seven.breadcrumbs.yml
index cbe50e64bc8..d31403117bc 100644
--- a/core/profiles/standard/config/block.block.seven.breadcrumbs.yml
+++ b/core/profiles/standard/config/block.block.seven.breadcrumbs.yml
@@ -1,4 +1,5 @@
-id: seven.breadcrumbs
+id: seven_breadcrumbs
+theme: seven
uuid: f8d0d0fb-daf7-4c91-8a09-9cb643279f03
weight: '-2'
status: '0'
diff --git a/core/profiles/standard/config/block.block.seven.content.yml b/core/profiles/standard/config/block.block.seven.content.yml
index 6e64d8935ed..39f26ffcd2b 100644
--- a/core/profiles/standard/config/block.block.seven.content.yml
+++ b/core/profiles/standard/config/block.block.seven.content.yml
@@ -1,4 +1,5 @@
-id: seven.content
+id: seven_content
+theme: seven
uuid: 3c9e3337-e0f4-42c3-8a00-f1d8be09b0ea
weight: '0'
status: '1'
diff --git a/core/profiles/standard/config/block.block.seven.help.yml b/core/profiles/standard/config/block.block.seven.help.yml
index ebfdfe7f641..8536232d6d0 100644
--- a/core/profiles/standard/config/block.block.seven.help.yml
+++ b/core/profiles/standard/config/block.block.seven.help.yml
@@ -1,4 +1,5 @@
-id: seven.help
+id: seven_help
+theme: seven
uuid: 367d09b7-9638-4faf-bf07-7fe31b2226a0
weight: '0'
status: '1'
diff --git a/core/profiles/standard/config/block.block.seven.login.yml b/core/profiles/standard/config/block.block.seven.login.yml
index 61c70b1dd55..d3e62fa0cf2 100644
--- a/core/profiles/standard/config/block.block.seven.login.yml
+++ b/core/profiles/standard/config/block.block.seven.login.yml
@@ -1,4 +1,5 @@
-id: seven.login
+id: seven_login
+theme: seven
uuid: 10a9888b-2247-408d-9702-2c0cc9cacba2
weight: '10'
status: '1'
diff --git a/core/profiles/standard/lib/Drupal/standard/Tests/StandardTest.php b/core/profiles/standard/lib/Drupal/standard/Tests/StandardTest.php
index 31fa0fe36c1..9857b8362b8 100644
--- a/core/profiles/standard/lib/Drupal/standard/Tests/StandardTest.php
+++ b/core/profiles/standard/lib/Drupal/standard/Tests/StandardTest.php
@@ -40,7 +40,7 @@ class StandardTest extends WebTestBase {
$this->drupalGet('admin/structure/block/add/system_menu_block:main/bartik');
$this->drupalPostForm(NULL, array(
'region' => 'sidebar_first',
- 'machine_name' => 'main_navigation',
+ 'id' => 'main_navigation',
), t('Save block'));
// Verify admin user can see the block.
$this->drupalGet('');
@@ -51,7 +51,7 @@ class StandardTest extends WebTestBase {
$this->drupalGet('admin/structure/block');
$elements = $this->xpath('//div[@role=:role and @id=:id]', array(
':role' => 'complementary',
- ':id' => 'block-help',
+ ':id' => 'block-bartik-help',
));
$this->assertEqual(count($elements), 1, 'Found complementary role on help block.');
@@ -59,7 +59,7 @@ class StandardTest extends WebTestBase {
$this->drupalGet('');
$elements = $this->xpath('//div[@role=:role and @id=:id]', array(
':role' => 'complementary',
- ':id' => 'block-powered',
+ ':id' => 'block-bartik-powered',
));
$this->assertEqual(count($elements), 1, 'Found complementary role on powered by block.');