From eb99b79be81ffe459069e65bbba48c352e1cd9d6 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Mon, 7 Mar 2016 14:45:59 +0000 Subject: [PATCH] Issue #2604974 by Chi, tstoeckler, dcrocks, Edit Olah: Hide "Powered by Drupal" block title by default --- core/modules/block/src/Tests/BlockTest.php | 12 +++++++----- .../system/src/Plugin/Block/SystemPoweredByBlock.php | 7 +++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/core/modules/block/src/Tests/BlockTest.php b/core/modules/block/src/Tests/BlockTest.php index 261c3ae6ddb7..cc8e974f046e 100644 --- a/core/modules/block/src/Tests/BlockTest.php +++ b/core/modules/block/src/Tests/BlockTest.php @@ -32,6 +32,7 @@ function testBlockVisibility() { 'id' => strtolower($this->randomMachineName(8)), 'region' => 'sidebar_first', 'settings[label]' => $title, + 'settings[label_display]' => TRUE, ); // Set the block to be hidden on any user path, and to be shown only to // authenticated users. @@ -142,11 +143,12 @@ function testBlock() { $block = array(); $block['id'] = 'system_powered_by_block'; $block['settings[label]'] = $this->randomMachineName(8); + $block['settings[label_display]'] = TRUE; $block['theme'] = $this->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]'], 'id' => $block['id'], 'region' => $block['region']), t('Save block')); + $this->drupalPostForm('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], array('settings[label]' => $block['settings[label]'], 'settings[label_display]' => $block['settings[label_display]'], '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 = Block::load($block['id']); @@ -255,19 +257,19 @@ function testHideBlockTitle() { $this->assertText('The block configuration has been saved.', 'Block was saved'); $this->drupalGet('user'); - $this->assertText($title, 'Block title was displayed by default.'); + $this->assertNoText($title, 'Block title was not displayed by default.'); $edit = array( - 'settings[label_display]' => FALSE, + 'settings[label_display]' => TRUE, ); $this->drupalPostForm('admin/structure/block/manage/' . $id, $edit, t('Save block')); $this->assertText('The block configuration has been saved.', 'Block was saved'); $this->drupalGet('admin/structure/block/manage/' . $id); - $this->assertNoFieldChecked('edit-settings-label-display', 'The display_block option has the correct default value on the configuration form.'); + $this->assertFieldChecked('edit-settings-label-display', 'The display_block option has the correct default value on the configuration form.'); $this->drupalGet('user'); - $this->assertNoText($title, 'Block title was not displayed when hidden.'); + $this->assertText($title, 'Block title was displayed when enabled.'); } /** diff --git a/core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php b/core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php index 25ea051ef4e8..a84c3fc2a89d 100644 --- a/core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php +++ b/core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php @@ -19,6 +19,13 @@ */ class SystemPoweredByBlock extends BlockBase { + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + return ['label_display' => FALSE]; + } + /** * {@inheritdoc} */ -- GitLab