diff --git a/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php index b578826..3f2ab8b 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskManager.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php @@ -319,7 +319,7 @@ public function getTasksBuild($current_route_name) { '#link' => $link, '#active' => $active, '#weight' => $child->getWeight(), - '#access' => $access = $this->accessManager->checkNamedRoute($route_name, $route_parameters, $this->account, TRUE), + '#access' => $this->accessManager->checkNamedRoute($route_name, $route_parameters, $this->account, TRUE), ); } } diff --git a/core/modules/aggregator/src/Tests/AggregatorTestBase.php b/core/modules/aggregator/src/Tests/AggregatorTestBase.php index 7a45c33..3af2217 100644 --- a/core/modules/aggregator/src/Tests/AggregatorTestBase.php +++ b/core/modules/aggregator/src/Tests/AggregatorTestBase.php @@ -43,7 +43,7 @@ protected function setUp() { $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'administer news feeds', 'access news feeds', 'create article content')); $this->drupalLogin($this->adminUser); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/block/src/Tests/BlockHiddenRegionTest.php b/core/modules/block/src/Tests/BlockHiddenRegionTest.php index 99d9deb..3ddcd82 100644 --- a/core/modules/block/src/Tests/BlockHiddenRegionTest.php +++ b/core/modules/block/src/Tests/BlockHiddenRegionTest.php @@ -42,7 +42,7 @@ protected function setUp() { $this->drupalLogin($this->adminUser); $this->drupalPlaceBlock('search_form_block'); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/block/src/Tests/BlockTest.php b/core/modules/block/src/Tests/BlockTest.php index 015d8a1..69f09b5 100644 --- a/core/modules/block/src/Tests/BlockTest.php +++ b/core/modules/block/src/Tests/BlockTest.php @@ -222,7 +222,7 @@ public function testBlockThemeSelector() { function testThemeName() { // Enable the help block. $this->drupalPlaceBlock('help_block', array('region' => 'help')); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); // Explicitly set the default and admin themes. $theme = 'block_test_specialchars_theme'; \Drupal::service('theme_handler')->install(array($theme)); diff --git a/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php b/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php index 27b0232..061dfa1 100644 --- a/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php +++ b/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php @@ -29,7 +29,7 @@ class NonDefaultBlockAdminTest extends WebTestBase { protected function setUp() { parent::setUp(); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/comment/src/Tests/CommentTestBase.php b/core/modules/comment/src/Tests/CommentTestBase.php index 3040c6a..e258fc8 100644 --- a/core/modules/comment/src/Tests/CommentTestBase.php +++ b/core/modules/comment/src/Tests/CommentTestBase.php @@ -86,7 +86,7 @@ protected function setUp() { // Create a test node authored by the web user. $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id())); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php index 634d934..c9a74fe 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php @@ -80,7 +80,7 @@ protected function setUp() { $this->config('locale.settings') ->set('translation.import_enabled', TRUE) ->save(); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php index 54decc8..b78b676 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php @@ -68,7 +68,7 @@ protected function setUp() { ConfigurableLanguage::createFromLangcode($langcode)->save(); } $this->localeStorage = $this->container->get('locale.storage'); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php index 7bbc9a2..080966d 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php @@ -118,7 +118,7 @@ protected function setUp() { ConfigurableLanguage::createFromLangcode($langcode)->save(); } $this->localeStorage = $this->container->get('locale.storage'); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php index 4a6380b..25931c9 100644 --- a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php +++ b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php @@ -32,7 +32,7 @@ protected function setUp() { parent::setUp(); $this->drupalLogin($this->rootUser); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php index 753ebfc..dc59162 100644 --- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php @@ -69,7 +69,7 @@ protected function setUp() { $this->drupalPlaceBlock('system_breadcrumb_block'); $this->drupalPlaceBlock('system_local_actions_block'); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); // Create a test user. $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer taxonomy', 'administer taxonomy_term fields', 'administer taxonomy_term display', 'administer users', 'administer account settings', 'administer user display', 'bypass node access')); diff --git a/core/modules/filter/src/Tests/FilterFormatAccessTest.php b/core/modules/filter/src/Tests/FilterFormatAccessTest.php index 5df5bdc..f165713 100644 --- a/core/modules/filter/src/Tests/FilterFormatAccessTest.php +++ b/core/modules/filter/src/Tests/FilterFormatAccessTest.php @@ -114,7 +114,7 @@ protected function setUp() { $this->secondAllowedFormat->getPermissionName(), $this->disallowedFormat->getPermissionName(), )); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/node/src/Tests/PageEditTest.php b/core/modules/node/src/Tests/PageEditTest.php index 9a9f28c..9ce1b71 100644 --- a/core/modules/node/src/Tests/PageEditTest.php +++ b/core/modules/node/src/Tests/PageEditTest.php @@ -28,7 +28,7 @@ protected function setUp() { $this->webUser = $this->drupalCreateUser(array('edit own page content', 'create page content')); $this->adminUser = $this->drupalCreateUser(array('bypass node access', 'administer nodes')); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php b/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php index 2965267..f19ac70 100644 --- a/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php +++ b/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php @@ -104,7 +104,7 @@ function testPageCacheTags() { 'config:block.block.bartik_account_menu', 'config:block.block.bartik_messages', 'config:block.block.bartik_local_actions', - 'config:block.block.bartik_tabs', + 'config:block.block.bartik_local_tasks', 'node_view', 'node:' . $node_1->id(), 'user:' . $author_1->id(), @@ -140,7 +140,7 @@ function testPageCacheTags() { 'config:block.block.bartik_account_menu', 'config:block.block.bartik_messages', 'config:block.block.bartik_local_actions', - 'config:block.block.bartik_tabs', + 'config:block.block.bartik_local_tasks', 'node_view', 'node:' . $node_2->id(), 'user:' . $author_2->id(), diff --git a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php index c897616..72bc6ac 100644 --- a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php +++ b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php @@ -58,7 +58,7 @@ protected function setUp() { // Enable the search block. $this->drupalPlaceBlock('search_form_block'); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/search/src/Tests/SearchPageTextTest.php b/core/modules/search/src/Tests/SearchPageTextTest.php index 368a1f0..8f21fbd 100644 --- a/core/modules/search/src/Tests/SearchPageTextTest.php +++ b/core/modules/search/src/Tests/SearchPageTextTest.php @@ -38,7 +38,7 @@ protected function setUp() { // Create user. $this->searchingUser = $this->drupalCreateUser(array('search content', 'access user profiles', 'use advanced search')); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/simpletest/src/Tests/BrowserTest.php b/core/modules/simpletest/src/Tests/BrowserTest.php index 6bfaf14..778198a 100644 --- a/core/modules/simpletest/src/Tests/BrowserTest.php +++ b/core/modules/simpletest/src/Tests/BrowserTest.php @@ -36,7 +36,7 @@ class BrowserTest extends WebTestBase { protected function setUp() { parent::setUp(); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/system/config/schema/system.schema.yml b/core/modules/system/config/schema/system.schema.yml index 3b7ed3f..8a1457d 100644 --- a/core/modules/system/config/schema/system.schema.yml +++ b/core/modules/system/config/schema/system.schema.yml @@ -353,7 +353,7 @@ block.settings.system_menu_block:*: type: integer label: 'Maximum number of levels' -block.settings.system_tabs_block: +block.settings.system_local_tasks_block: type: block_settings label: 'Tabs block' mapping: diff --git a/core/modules/system/src/Plugin/Block/SystemLocalTasksBlock.php b/core/modules/system/src/Plugin/Block/SystemLocalTasksBlock.php new file mode 100644 index 0000000..bbbbb9d --- /dev/null +++ b/core/modules/system/src/Plugin/Block/SystemLocalTasksBlock.php @@ -0,0 +1,146 @@ + FALSE, + 'primary' => TRUE, + 'secondary' => TRUE, + ]; + } + + /** + * {@inheritdoc} + */ + public function build() { + $config = $this->configuration; + + $tabs = [ + '#theme' => 'menu_local_tasks', + ]; + + // Add only selected levels for the printed output. + if ($config['primary']) { + $tabs += [ + '#primary' => menu_primary_local_tasks(), + ]; + } + if ($config['secondary']) { + $tabs += [ + '#secondary' => menu_secondary_local_tasks(), + ]; + } + + if (empty($tabs['#primary']) && empty($tabs['#secondary'])) { + return []; + } + + $build['tabs'] = $tabs; + + return $build; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $form = parent::buildConfigurationForm($form, $form_state); + + // The "Page actions" block is never cacheable because of hooks creating + // local tasks doesn't provide cacheability metadata. + // @todo Remove after https://www.drupal.org/node/2511516 has landed. + $form['cache']['#disabled'] = TRUE; + $form['cache']['#description'] = $this->t('This block is never cacheable.'); + $form['cache']['max_age']['#value'] = 0; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function getCacheMaxAge() { + // @todo Remove after https://www.drupal.org/node/2511516 has landed. + return 0; + } + + /** + * {@inheritdoc} + */ + public function getCacheContexts() { + return ['route.name']; + } + + /** + * {@inheritdoc} + */ + public function blockForm($form, FormStateInterface $form_state) { + $config = $this->configuration; + $defaults = $this->defaultConfiguration(); + + $form['levels'] = array( + '#type' => 'details', + '#title' => $this->t('Shown tabs'), + '#description' => $this->t('Select tabs being shown in the block'), + // Open if not set to defaults. + '#open' => $defaults['primary'] !== $config['primary'] || $defaults['secondary'] !== $config['secondary'], + ); + $form['levels']['primary'] = [ + '#type' => 'checkbox', + '#title' => $this->t('Show primary tabs'), + '#default_value' => $config['primary'], + ]; + $form['levels']['secondary'] = [ + '#type' => 'checkbox', + '#title' => $this->t('Show secondary tabs'), + '#default_value' => $config['secondary'], + ]; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function blockSubmit($form, FormStateInterface $form_state) { + $levels = $form_state->getValue('levels'); + $this->configuration['primary'] = $levels['primary']; + $this->configuration['secondary'] = $levels['secondary']; + } + +} diff --git a/core/modules/system/src/Plugin/Block/SystemTabsBlock.php b/core/modules/system/src/Plugin/Block/SystemTabsBlock.php deleted file mode 100644 index 9168455..0000000 --- a/core/modules/system/src/Plugin/Block/SystemTabsBlock.php +++ /dev/null @@ -1,146 +0,0 @@ - FALSE, - 'primary' => TRUE, - 'secondary' => TRUE, - ]; - } - - /** - * {@inheritdoc} - */ - public function build() { - $config = $this->configuration; - - $tabs = [ - '#theme' => 'menu_local_tasks', - ]; - - // Add only selected levels for the printed output. - if ($config['primary']) { - $tabs += [ - '#primary' => menu_primary_local_tasks(), - ]; - } - if ($config['secondary']) { - $tabs += [ - '#secondary' => menu_secondary_local_tasks(), - ]; - } - - if (empty($tabs['#primary']) && empty($tabs['#secondary'])) { - return []; - } - - $build['tabs'] = $tabs; - - return $build; - } - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form = parent::buildConfigurationForm($form, $form_state); - - // The "Page actions" block is never cacheable because of hooks creating - // local tasks doesn't provide cacheability metadata. - // @todo Remove after https://www.drupal.org/node/2511516 has landed. - $form['cache']['#disabled'] = TRUE; - $form['cache']['#description'] = $this->t('This block is never cacheable.'); - $form['cache']['max_age']['#value'] = 0; - - return $form; - } - - /** - * {@inheritdoc} - */ - public function getCacheMaxAge() { - // @todo Remove after https://www.drupal.org/node/2511516 has landed. - return 0; - } - - /** - * {@inheritdoc} - */ - public function getCacheContexts() { - return ['route.name']; - } - - /** - * {@inheritdoc} - */ - public function blockForm($form, FormStateInterface $form_state) { - $config = $this->configuration; - $defaults = $this->defaultConfiguration(); - - $form['levels'] = array( - '#type' => 'details', - '#title' => $this->t('Shown tabs'), - '#description' => $this->t('Select tabs being shown in the block'), - // Open if not set to defaults. - '#open' => $defaults['primary'] !== $config['primary'] || $defaults['secondary'] !== $config['secondary'], - ); - $form['levels']['primary'] = [ - '#type' => 'checkbox', - '#title' => $this->t('Show primary tabs'), - '#default_value' => $config['primary'], - ]; - $form['levels']['secondary'] = [ - '#type' => 'checkbox', - '#title' => $this->t('Show secondary tabs'), - '#default_value' => $config['secondary'], - ]; - - return $form; - } - - /** - * {@inheritdoc} - */ - public function blockSubmit($form, FormStateInterface $form_state) { - $levels = $form_state->getValue('levels'); - $this->configuration['primary'] = $levels['primary']; - $this->configuration['secondary'] = $levels['secondary']; - } - -} diff --git a/core/modules/system/src/Tests/Menu/LocalTasksTest.php b/core/modules/system/src/Tests/Menu/LocalTasksTest.php index c3d8972..472dba2 100644 --- a/core/modules/system/src/Tests/Menu/LocalTasksTest.php +++ b/core/modules/system/src/Tests/Menu/LocalTasksTest.php @@ -37,7 +37,7 @@ class LocalTasksTest extends WebTestBase { protected function setUp() { parent::setUp(); - $this->sut = $this->drupalPlaceBlock('system_tabs_block', ['id' => 'tabs_block']); + $this->sut = $this->drupalPlaceBlock('system_local_tasks_block', ['id' => 'tabs_block']); } /** @@ -213,7 +213,7 @@ public function testLocalTaskBlock() { // Remove the default block and create a new one. $this->sut->delete(); - $this->sut = $this->drupalPlaceBlock('system_tabs_block', [ + $this->sut = $this->drupalPlaceBlock('system_local_tasks_block', [ 'id' => 'tabs_block', 'primary' => TRUE, 'secondary' => FALSE, @@ -232,7 +232,7 @@ public function testLocalTaskBlock() { $this->assertNoLocalTasks(1); $this->sut->delete(); - $this->sut = $this->drupalPlaceBlock('system_tabs_block', [ + $this->sut = $this->drupalPlaceBlock('system_local_tasks_block', [ 'id' => 'tabs_block', 'primary' => FALSE, 'secondary' => TRUE, diff --git a/core/modules/system/src/Tests/Menu/MenuRouterTest.php b/core/modules/system/src/Tests/Menu/MenuRouterTest.php index bab9635..863a30c 100644 --- a/core/modules/system/src/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/src/Tests/Menu/MenuRouterTest.php @@ -43,7 +43,7 @@ protected function setUp() { parent::setUp(); $this->drupalPlaceBlock('system_menu_block:tools'); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/system/src/Tests/Menu/MenuTranslateTest.php b/core/modules/system/src/Tests/Menu/MenuTranslateTest.php index e02a304..aadf565 100644 --- a/core/modules/system/src/Tests/Menu/MenuTranslateTest.php +++ b/core/modules/system/src/Tests/Menu/MenuTranslateTest.php @@ -31,7 +31,7 @@ class MenuTranslateTest extends WebTestBase { protected function setUp() { parent::setUp(); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/system/src/Tests/System/ThemeTest.php b/core/modules/system/src/Tests/System/ThemeTest.php index e97c75b..634a8e7 100644 --- a/core/modules/system/src/Tests/System/ThemeTest.php +++ b/core/modules/system/src/Tests/System/ThemeTest.php @@ -40,7 +40,7 @@ protected function setUp() { $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer themes', 'bypass node access', 'administer blocks')); $this->drupalLogin($this->adminUser); $this->node = $this->drupalCreateNode(); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/system/src/Tests/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php b/core/modules/system/src/Tests/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php index eb0f1e8..6da5115 100644 --- a/core/modules/system/src/Tests/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php +++ b/core/modules/system/src/Tests/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php @@ -27,15 +27,17 @@ protected function setUp() { __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.local-actions-tasks-into-blocks-507488.php', ]; parent::setUp(); - \Drupal::service('theme_handler')->install(['test_theme']); } /** * Tests that local actions/tasks are being converted into blocks. */ public function testUpdateHookN() { + /** @var \Drupal\block\BlockInterface $block_storage */ + $block_storage = \Drupal::entityManager()->getStorage('block'); /* @var \Drupal\block\BlockInterface[] $help_blocks */ - $help_blocks = entity_load_multiple_by_properties('block', ['region' => 'help']); + $help_blocks = $block_storage->loadByProperties(['theme' => 'bartik', 'region' => 'help']); + $this->runUpdates(); $this->assertRaw('Because your site has custom theme(s) installed, we had to set local actions and tasks blocks into the content region. Please manually review the block configurations and remove the removed variables from your templates.'); @@ -47,8 +49,6 @@ public function testUpdateHookN() { // Ensures that blocks inside help region has been moved to content region. foreach ($help_blocks as $block) { - /** @var \Drupal\block\BlockInterface $block_storage */ - $block_storage = \Drupal::entityManager()->getStorage('block'); $new_block = $block_storage->load($block->id()); $this->assertEqual($new_block->getRegion(), 'content'); } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index bb12067..3a8e7a6 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1099,6 +1099,7 @@ function system_update_8001() { if (!\Drupal::moduleHandler()->moduleExists('block')) { return t('Block module is not enabled so local actions and tasks which have been converted to blocks, are not visible anymore.'); } + $config_factory = \Drupal::configFactory(); /** @var \Drupal\Core\Extension\ThemeHandler $theme_handler */ $theme_handler = \Drupal::service('theme_handler'); /** @var \Drupal\Core\Config\StorageInterface $config_storage */ @@ -1118,7 +1119,7 @@ function system_update_8001() { ], ]; $tabs_default_settings = [ - 'plugin' => 'system_tabs_block', + 'plugin' => 'system_local_tasks_block', 'region' => 'content', 'label' => 'Tabs', 'visibility' => [], @@ -1142,9 +1143,9 @@ function system_update_8001() { ] + $local_actions_default_settings; $block_storage->create($values)->save(); } - if (!$config_storage->exists('block.block.bartik_tabs')) { + if (!$config_storage->exists('block.block.bartik_local_tasks')) { $values = [ - 'id' => 'bartik_tabs', + 'id' => 'bartik_local_tasks', 'theme' => 'bartik', 'weight' => -7, ] + $tabs_default_settings; @@ -1154,13 +1155,14 @@ function system_update_8001() { // Help region has been removed so all the blocks inside has to be moved // to content region. /* @var \Drupal\block\BlockInterface[] $help_blocks */ - $help_blocks = entity_load_multiple_by_properties('block', ['region' => 'help']); + $help_blocks = $block_storage->loadByProperties(['theme' => 'bartik', 'region' => 'help']); uasort($help_blocks, array('Drupal\Component\Utility\SortArray', 'sortByWeightProperty')); $weight = -6; foreach ($help_blocks as $block) { - $block->setRegion('content'); - $block->setWeight($weight); - $block->save(); + $block_config = $config_factory->getEditable('block.block.' . $block->getConfigTarget()); + $block_config->set('region', 'content'); + $block_config->set('weight', $weight); + $block_config->save(); $weight++; } break; @@ -1174,10 +1176,10 @@ function system_update_8001() { ] + $local_actions_default_settings; $block_storage->create($values)->save(); } - if (!$config_storage->exists('block.block.seven_primary_tabs')) { + if (!$config_storage->exists('block.block.seven_primary_local_tasks')) { $values = [ 'region' => 'header', - 'id' => 'seven_primary_tabs', + 'id' => 'seven_primary_local_tasks', 'theme' => 'seven', 'label' => 'Primary tabs', 'settings' => [ @@ -1188,10 +1190,10 @@ function system_update_8001() { $block_storage->create($values)->save(); } - if (!$config_storage->exists('block.block.seven_secondary_tabs')) { + if (!$config_storage->exists('block.block.seven_secondary_local_tasks')) { $values = [ 'region' => 'pre_content', - 'id' => 'seven_secondary_tabs', + 'id' => 'seven_secondary_local_tasks', 'theme' => 'seven', 'label' => 'Secondary tabs', 'settings' => [ @@ -1211,9 +1213,9 @@ function system_update_8001() { ] + $local_actions_default_settings; $block_storage->create($values)->save(); } - if (!$config_storage->exists('block.block.stark_tabs')) { + if (!$config_storage->exists('block.block.stark_local_tasks')) { $values = [ - 'id' => 'stark_tabs', + 'id' => 'stark_local_tasks', 'theme' => 'stark', ] + $tabs_default_settings; $block_storage->create($values)->save(); @@ -1234,9 +1236,9 @@ function system_update_8001() { ] + $local_actions_default_settings; $block_storage->create($values)->save(); } - if (!$config_storage->exists(sprintf('block.block.%s_tabs', $theme_name))) { + if (!$config_storage->exists(sprintf('block.block.%s_local_tasks', $theme_name))) { $values = [ - 'id' => sprintf('%s_tabs', $theme_name), + 'id' => sprintf('%s_local_tasks', $theme_name), 'theme' => $theme_name, 'weight' => -20, ] + $tabs_default_settings; diff --git a/core/modules/system/system.module b/core/modules/system/system.module index cd12fd1..6f807b3 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -808,7 +808,7 @@ function system_preprocess_block(&$variables) { $variables['content'] = $variables['content']['local_actions']; break; - case 'system_tabs_block': + case 'system_local_tasks_block': $variables['content'] = $variables['content']['tabs']; break; diff --git a/core/modules/system/tests/fixtures/update/drupal-8.local-actions-tasks-into-blocks-507488.php b/core/modules/system/tests/fixtures/update/drupal-8.local-actions-tasks-into-blocks-507488.php index 305ae3c..986362f 100644 --- a/core/modules/system/tests/fixtures/update/drupal-8.local-actions-tasks-into-blocks-507488.php +++ b/core/modules/system/tests/fixtures/update/drupal-8.local-actions-tasks-into-blocks-507488.php @@ -44,3 +44,17 @@ ->condition('collection', 'config.entity.key_store.block') ->condition('name', 'theme:seven') ->execute(); + +// Enable test theme. +$extensions = $connection->select('config') + ->fields('config', ['data']) + ->condition('name', 'core.extension') + ->execute() + ->fetchField(); +$extensions = unserialize($extensions); +$connection->update('config') + ->fields([ + 'data' => serialize(array_merge_recursive($extensions, ['theme' => ['test_theme' => 0]])) + ]) + ->condition('name', 'core.extension') + ->execute(); diff --git a/core/modules/taxonomy/src/Tests/TermTest.php b/core/modules/taxonomy/src/Tests/TermTest.php index 1ef3e47..66fa145 100644 --- a/core/modules/taxonomy/src/Tests/TermTest.php +++ b/core/modules/taxonomy/src/Tests/TermTest.php @@ -49,7 +49,7 @@ protected function setUp() { parent::setUp(); $this->drupalPlaceBlock('system_local_actions_block'); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'bypass node access'])); $this->vocabulary = $this->createVocabulary(); diff --git a/core/modules/tracker/src/Tests/TrackerTest.php b/core/modules/tracker/src/Tests/TrackerTest.php index 5598ce9..611719b 100644 --- a/core/modules/tracker/src/Tests/TrackerTest.php +++ b/core/modules/tracker/src/Tests/TrackerTest.php @@ -60,7 +60,7 @@ protected function setUp() { 'access content', 'access user profiles', )); - $this->drupalPlaceBlock('system_tabs_block', ['id' => 'page_tabs_block']); + $this->drupalPlaceBlock('system_local_tasks_block', ['id' => 'page_tabs_block']); $this->drupalPlaceBlock('system_local_actions_block', ['id' => 'page_actions_block']); } diff --git a/core/modules/user/src/Tests/UserRoleAdminTest.php b/core/modules/user/src/Tests/UserRoleAdminTest.php index 7d0d350..533e6bf 100644 --- a/core/modules/user/src/Tests/UserRoleAdminTest.php +++ b/core/modules/user/src/Tests/UserRoleAdminTest.php @@ -38,7 +38,7 @@ class UserRoleAdminTest extends WebTestBase { protected function setUp() { parent::setUp(); $this->adminUser = $this->drupalCreateUser(array('administer permissions', 'administer users')); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php b/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php index dddd4ce..83bf412 100644 --- a/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php +++ b/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php @@ -40,7 +40,7 @@ protected function setUp() { parent::setUp(); $this->enableViewsTestModule(); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/modules/views_ui/src/Tests/SettingsTest.php b/core/modules/views_ui/src/Tests/SettingsTest.php index 62acd9d..43bbc9b 100644 --- a/core/modules/views_ui/src/Tests/SettingsTest.php +++ b/core/modules/views_ui/src/Tests/SettingsTest.php @@ -26,7 +26,7 @@ class SettingsTest extends UITestBase { */ protected function setUp() { parent::setUp(); - $this->drupalPlaceBlock('system_tabs_block'); + $this->drupalPlaceBlock('system_local_tasks_block'); } /** diff --git a/core/profiles/minimal/config/install/block.block.stark_local_tasks.yml b/core/profiles/minimal/config/install/block.block.stark_local_tasks.yml new file mode 100644 index 0000000..1d7d1b7 --- /dev/null +++ b/core/profiles/minimal/config/install/block.block.stark_local_tasks.yml @@ -0,0 +1,18 @@ +id: stark_local_tasks +theme: stark +weight: -20 +status: true +langcode: en +region: content +plugin: system_local_tasks_block +settings: + id: system_local_tasks_block + label: Tabs + provider: system + label_display: '0' +dependencies: + module: + - system + theme: + - stark +visibility: { } diff --git a/core/profiles/minimal/config/install/block.block.stark_tabs.yml b/core/profiles/minimal/config/install/block.block.stark_tabs.yml deleted file mode 100644 index 1c2cff3c..0000000 --- a/core/profiles/minimal/config/install/block.block.stark_tabs.yml +++ /dev/null @@ -1,18 +0,0 @@ -id: bartik_tabs -theme: stark -weight: -20 -status: true -langcode: en -region: content -plugin: system_tabs_block -settings: - id: system_tabs_block - label: Tabs - provider: system - label_display: '0' -dependencies: - module: - - system - theme: - - stark -visibility: { } diff --git a/core/profiles/standard/config/install/block.block.bartik_local_tasks.yml b/core/profiles/standard/config/install/block.block.bartik_local_tasks.yml new file mode 100644 index 0000000..532a1e3 --- /dev/null +++ b/core/profiles/standard/config/install/block.block.bartik_local_tasks.yml @@ -0,0 +1,18 @@ +id: bartik_local_tasks +theme: bartik +weight: -40 +status: true +langcode: en +region: content +plugin: system_local_tasks_block +settings: + id: system_local_tasks_block + label: Tabs + provider: system + label_display: '0' +dependencies: + module: + - system + theme: + - bartik +visibility: { } diff --git a/core/profiles/standard/config/install/block.block.bartik_tabs.yml b/core/profiles/standard/config/install/block.block.bartik_tabs.yml deleted file mode 100644 index 8e72822..0000000 --- a/core/profiles/standard/config/install/block.block.bartik_tabs.yml +++ /dev/null @@ -1,18 +0,0 @@ -id: bartik_tabs -theme: bartik -weight: -40 -status: true -langcode: en -region: content -plugin: system_tabs_block -settings: - id: system_tabs_block - label: Tabs - provider: system - label_display: '0' -dependencies: - module: - - system - theme: - - bartik -visibility: { } diff --git a/core/profiles/standard/config/install/block.block.seven_page_primary_tabs.yml b/core/profiles/standard/config/install/block.block.seven_page_primary_tabs.yml deleted file mode 100644 index 078f15b..0000000 --- a/core/profiles/standard/config/install/block.block.seven_page_primary_tabs.yml +++ /dev/null @@ -1,20 +0,0 @@ -id: seven_primary_tabs -theme: seven -weight: 0 -status: true -langcode: en -region: header -plugin: system_tabs_block -settings: - id: system_tabs_block - label: Primary tabs - provider: system - label_display: '0' - primary: true - secondary: false -dependencies: - module: - - system - theme: - - seven -visibility: { } diff --git a/core/profiles/standard/config/install/block.block.seven_page_seconadry_tabs.yml b/core/profiles/standard/config/install/block.block.seven_page_seconadry_tabs.yml deleted file mode 100644 index a7e2350..0000000 --- a/core/profiles/standard/config/install/block.block.seven_page_seconadry_tabs.yml +++ /dev/null @@ -1,20 +0,0 @@ -id: seven_secondary_tabs -theme: seven -weight: 0 -status: true -langcode: en -region: pre_content -plugin: system_tabs_block -settings: - id: system_tabs_block - label: Secondary tabs - provider: system - label_display: '0' - primary: false - secondary: true -dependencies: - module: - - system - theme: - - seven -visibility: { } diff --git a/core/profiles/standard/config/install/block.block.seven_primary_local_tasks.yml b/core/profiles/standard/config/install/block.block.seven_primary_local_tasks.yml new file mode 100644 index 0000000..4899cf1 --- /dev/null +++ b/core/profiles/standard/config/install/block.block.seven_primary_local_tasks.yml @@ -0,0 +1,20 @@ +id: seven_primary_local_tasks +theme: seven +weight: 0 +status: true +langcode: en +region: header +plugin: system_local_tasks_block +settings: + id: system_local_tasks_block + label: Primary tabs + provider: system + label_display: '0' + primary: true + secondary: false +dependencies: + module: + - system + theme: + - seven +visibility: { } diff --git a/core/profiles/standard/config/install/block.block.seven_seconadry_local_tasks.yml b/core/profiles/standard/config/install/block.block.seven_seconadry_local_tasks.yml new file mode 100644 index 0000000..cc83531 --- /dev/null +++ b/core/profiles/standard/config/install/block.block.seven_seconadry_local_tasks.yml @@ -0,0 +1,20 @@ +id: seven_secondary_local_tasks +theme: seven +weight: 0 +status: true +langcode: en +region: pre_content +plugin: system_local_tasks_block +settings: + id: system_local_tasks_block + label: Secondary tabs + provider: system + label_display: '0' + primary: false + secondary: true +dependencies: + module: + - system + theme: + - seven +visibility: { }