diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php index 071f5a4..99988bb 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php @@ -34,60 +34,82 @@ function setUp() { ->set('slogan', 'Community plumbing') ->save(); // Add the system branding block to the page. - $this->drupalPlaceBlock('system_branding_block', array('region' => 'header', 'id' => 'sitebranding')); + $this->drupalPlaceBlock('system_branding_block', array('region' => 'header', 'id' => 'site-branding')); } /** * Tests system branding block configuration. */ function testSystemBrandingSettings() { - // With the default block settings, test that all branding elements are - // displayed. + // Set default block settings and test that all branding elements are displayed. $this->drupalGet(''); - $logo_element = $this->xpath('//div[@id="block-sitebranding"]//a[@class="site-logo"]'); - $sitename_element = $this->xpath('//div[@id="block-sitebranding"]//strong[@class="site-name"]'); - $slogan_element = $this->xpath('//div[@id="block-sitebranding"]//div[@class="site-slogan"]'); - $this->assertTrue(!empty($logo_element), 'The branding block logo was found.'); - $this->assertTrue(!empty($sitename_element), 'The branding block site name was found.'); - $this->assertTrue(!empty($slogan_element), 'The branding block slogan was found.'); + $site_logo_element = $this->xpath('//div[@id="block-site-branding"]//a[@class="site-logo"]'); + $site_name_slogan_element = $this->xpath('//div[@id="block-site-branding"]//div[@class="name-and-slogan"]'); + $site_name_element = $this->xpath('//div[@id="block-site-branding"]//strong[@class="site-name"]'); + $site_slogan_element = $this->xpath('//div[@id="block-site-branding"]//div[@class="site-slogan"]'); + $this->assertTrue(!empty($site_logo_element), 'The branding block logo was found.'); + $this->assertTrue(!empty($site_name_slogan_element), 'The branding block name and slogan div was found.'); + $this->assertTrue(!empty($site_name_element), 'The branding block site name was found.'); + $this->assertTrue(!empty($site_slogan_element), 'The branding block slogan was found.'); // Turn just the logo off, and re-test all branding elements. - \Drupal::config('block.block.sitebranding') - ->set('settings.site_logo', 0) + \Drupal::config('block.block.site-branding') + ->set('settings.use_site_logo', 0) ->save(); $this->drupalGet(''); - $logo_element = $this->xpath('//div[@id="block-sitebranding"]//a[@class="site-logo"]'); - $sitename_element = $this->xpath('//div[@id="block-sitebranding"]//strong[@class="site-name"]'); - $slogan_element = $this->xpath('//div[@id="block-sitebranding"]//div[@class="site-slogan"]'); - $this->assertTrue(empty($logo_element), 'The branding block logo was disabled.'); - $this->assertTrue(!empty($sitename_element), 'The branding block site name was found.'); - $this->assertTrue(!empty($slogan_element), 'The branding block slogan was found.'); + $site_logo_element = $this->xpath('//div[@id="block-site-branding"]//a[@class="site-logo"]'); + $site_name_slogan_element = $this->xpath('//div[@id="block-site-branding"]//div[@class="name-and-slogan"]'); + $site_name_element = $this->xpath('//div[@id="block-site-branding"]//strong[@class="site-name"]'); + $site_slogan_element = $this->xpath('//div[@id="block-site-branding"]//div[@class="site-slogan"]'); + $this->assertTrue(empty($site_logo_element), 'The branding block logo was disabled.'); + $this->assertTrue(!empty($site_name_slogan_element), 'The branding block name and slogan div was found.'); + $this->assertTrue(!empty($site_name_element), 'The branding block site name was found.'); + $this->assertTrue(!empty($site_slogan_element), 'The branding block slogan was found.'); // Turn just the site name off, and re-test all branding elements. - \Drupal::config('block.block.sitebranding') - ->set('settings.site_logo', 1) - ->set('settings.site_name', 0) + \Drupal::config('block.block.site-branding') + ->set('settings.use_site_logo', 1) + ->set('settings.use_site_name', 0) ->save(); $this->drupalGet(''); - $logo_element = $this->xpath('//div[@id="block-sitebranding"]//a[@class="site-logo"]'); - $sitename_element = $this->xpath('//div[@id="block-sitebranding"]//strong[@class="site-name"]'); - $slogan_element = $this->xpath('//div[@id="block-sitebranding"]//div[@class="site-slogan"]'); - $this->assertTrue(!empty($logo_element), 'The branding block logo was found.'); - $this->assertTrue(empty($sitename_element), 'The branding block site name was disabled.'); - $this->assertTrue(!empty($slogan_element), 'The branding block slogan was found.'); + $site_logo_element = $this->xpath('//div[@id="block-site-branding"]//a[@class="site-logo"]'); + $site_name_slogan_element = $this->xpath('//div[@id="block-site-branding"]//div[@class="name-and-slogan"]'); + $site_name_element = $this->xpath('//div[@id="block-site-branding"]//strong[@class="site-name"]'); + $site_slogan_element = $this->xpath('//div[@id="block-site-branding"]//div[@class="site-slogan"]'); + $this->assertTrue(!empty($site_logo_element), 'The branding block logo was found.'); + $this->assertTrue(!empty($site_name_slogan_element), 'The branding block name and slogan div was found.'); + $this->assertTrue(empty($site_name_element), 'The branding block site name was disabled.'); + $this->assertTrue(!empty($site_slogan_element), 'The branding block slogan was found.'); // Turn just the site slogan off, and re-test all branding elements. - \Drupal::config('block.block.sitebranding') - ->set('settings.site_name', 1) - ->set('settings.site_slogan', 0) + \Drupal::config('block.block.site-branding') + ->set('settings.use_site_name', 1) + ->set('settings.use_site_slogan', 0) ->save(); $this->drupalGet(''); - $logo_element = $this->xpath('//div[@id="block-sitebranding"]//a[@class="site-logo"]'); - $sitename_element = $this->xpath('//div[@id="block-sitebranding"]//strong[@class="site-name"]'); - $slogan_element = $this->xpath('//div[@id="block-sitebranding"]//div[@class="site-slogan"]'); - $this->assertTrue(!empty($logo_element), 'The branding block logo was found.'); - $this->assertTrue(!empty($sitename_element), 'The branding block site name was found.'); - $this->assertTrue(empty($slogan_element), 'The branding block slogan was disabled.'); + $site_logo_element = $this->xpath('//div[@id="block-site-branding"]//a[@class="site-logo"]'); + $site_name_slogan_element = $this->xpath('//div[@id="block-site-branding"]//div[@class="name-and-slogan"]'); + $site_name_element = $this->xpath('//div[@id="block-site-branding"]//strong[@class="site-name"]'); + $site_slogan_element = $this->xpath('//div[@id="block-site-branding"]//div[@class="site-slogan"]'); + $this->assertTrue(!empty($site_logo_element), 'The branding block logo was found.'); + $this->assertTrue(!empty($site_name_slogan_element), 'The branding block name and slogan div was found.'); + $this->assertTrue(!empty($site_name_element), 'The branding block site name was found.'); + $this->assertTrue(empty($site_slogan_element), 'The branding block slogan was disabled.'); + + // Turn the site name and the site slogan off, and re-test all branding elements. + \Drupal::config('block.block.site-branding') + ->set('settings.use_site_name', 0) + ->set('settings.use_site_slogan', 0) + ->save(); + $this->drupalGet(''); + $site_logo_element = $this->xpath('//div[@id="block-site-branding"]//a[@class="site-logo"]'); + $site_name_slogan_element = $this->xpath('//div[@id="block-site-branding"]//div[@class="name-and-slogan"]'); + $site_name_element = $this->xpath('//div[@id="block-site-branding"]//strong[@class="site-name"]'); + $site_slogan_element = $this->xpath('//div[@id="block-site-branding"]//div[@class="site-slogan"]'); + $this->assertTrue(!empty($site_logo_element), 'The branding block logo was found.'); + $this->assertTrue(empty($site_name_slogan_element), 'The branding block name and slogan div was found.'); + $this->assertTrue(empty($site_name_element), 'The branding block site name was found.'); + $this->assertTrue(empty($site_slogan_element), 'The branding block slogan was disabled.'); } diff --git a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemBrandingBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemBrandingBlock.php index da9d2b8..6336809 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemBrandingBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemBrandingBlock.php @@ -64,9 +64,9 @@ public static function create(ContainerInterface $container, array $configuratio */ public function defaultConfiguration() { return array( - 'site_logo' => TRUE, - 'site_name' => TRUE, - 'site_slogan' => TRUE, + 'use_site_logo' => TRUE, + 'use_site_name' => TRUE, + 'use_site_slogan' => TRUE, 'label_display' => FALSE, ); } @@ -82,20 +82,20 @@ public function blockForm($form, &$form_state) { '#collapsed' => FALSE, '#collapsible' => FALSE, ); - $form['block_branding']['site_logo'] = array( + $form['block_branding']['use_site_logo'] = array( '#type' => 'checkbox', '#title' => $this->t('Site logo'), - '#default_value' => $this->configuration['site_logo'], + '#default_value' => $this->configuration['use_site_logo'], ); - $form['block_branding']['site_name'] = array( + $form['block_branding']['use_site_name'] = array( '#type' => 'checkbox', '#title' => $this->t('Site name'), - '#default_value' => $this->configuration['site_name'], + '#default_value' => $this->configuration['use_site_name'], ); - $form['block_branding']['site_slogan'] = array( + $form['block_branding']['use_site_slogan'] = array( '#type' => 'checkbox', '#title' => $this->t('Site slogan'), - '#default_value' => $this->configuration['site_slogan'], + '#default_value' => $this->configuration['use_site_slogan'], ); return $form; } @@ -104,9 +104,9 @@ public function blockForm($form, &$form_state) { * {@inheritdoc} */ public function blockSubmit($form, &$form_state) { - $this->configuration['site_logo'] = $form_state['values']['block_branding']['site_logo']; - $this->configuration['site_name'] = $form_state['values']['block_branding']['site_name']; - $this->configuration['site_slogan'] = $form_state['values']['block_branding']['site_slogan']; + $this->configuration['use_site_logo'] = $form_state['values']['block_branding']['use_site_logo']; + $this->configuration['use_site_name'] = $form_state['values']['block_branding']['use_site_name']; + $this->configuration['use_site_slogan'] = $form_state['values']['block_branding']['use_site_slogan']; } /** @@ -117,13 +117,13 @@ public function build() { $site_config = $this->configFactory->get('system.site'); $build['#theme'] = 'branding'; - $build['#use_site_logo'] = $this->configuration['site_logo']; + $build['#use_site_logo'] = $this->configuration['use_site_logo']; $build['#site_logo'] = theme_get_setting('logo'); - $build['#use_site_name'] = $this->configuration['site_name']; + $build['#use_site_name'] = $this->configuration['use_site_name']; $build['#site_name'] = $site_config->get('name'); - $build['#use_site_slogan'] = $this->configuration['site_slogan']; + $build['#use_site_slogan'] = $this->configuration['use_site_slogan']; $build['#site_slogan'] = Xss::filterAdmin($site_config->get('slogan')); return $build; diff --git a/core/modules/system/templates/branding.html.twig b/core/modules/system/templates/branding.html.twig index 6c77bbf..bfcbc08 100644 --- a/core/modules/system/templates/branding.html.twig +++ b/core/modules/system/templates/branding.html.twig @@ -21,9 +21,9 @@ {% endif %} -{% if use_site_logo or (use_site_slogan and site_slogan) %} +{% if use_site_name or (use_site_slogan and site_slogan) %} -
+
{% if use_site_name %} @@ -35,6 +35,6 @@
{{ site_slogan|t }}
{% endif %} -
{# /.name-and-slogan #} +
{% endif %}