diff --git a/html/modules/custom/bc_dc/bc_dc.module b/html/modules/custom/bc_dc/bc_dc.module index 90ac6034..4d202233 100644 --- a/html/modules/custom/bc_dc/bc_dc.module +++ b/html/modules/custom/bc_dc/bc_dc.module @@ -952,6 +952,19 @@ function bc_dc_preprocess_links__toolbar_user(array &$variables): void { } } +/** + * Implements hook_preprocess_HOOK() for breadcrumb. + */ +function bc_dc_preprocess_breadcrumb(array &$variables): void { + // Set the "Home" breadcrumb link text to the site name. + foreach ($variables['links'] ?? [] as $key => $link) { + if ($link->getUrl()->getRouteName() === '') { + $site_name = \Drupal::config('system.site')->get('name'); + $variables['breadcrumb'][$key]['text'] = $site_name; + } + } +} + /** * Implements hook_system_breadcrumb_alter(). */ diff --git a/html/modules/custom/bc_dc/tests/src/Functional/BcDcFunctionalTest.php b/html/modules/custom/bc_dc/tests/src/Functional/BcDcFunctionalTest.php index 5c893323..a67d16a1 100644 --- a/html/modules/custom/bc_dc/tests/src/Functional/BcDcFunctionalTest.php +++ b/html/modules/custom/bc_dc/tests/src/Functional/BcDcFunctionalTest.php @@ -196,6 +196,9 @@ public function test(): void { // Module configuration. // @todo Remove this section and have the config come in from config import. // + // Set site name. + $site_name = 'Site name ' . $this->randomString(); + $this->config('system.site')->set('name', $site_name)->save(); // Configure registration_role module. $this->drupalGet('admin/people/registration-role'); $edit = [ @@ -419,6 +422,7 @@ public function test(): void { $breadcrumbs = $this->xpath('//ol[@class = "breadcrumb"]/li/a'); $this->assertCount(1, $breadcrumbs, 'Page has 1 breadcrumb.'); $this->assertEquals('/', $breadcrumbs[0]->getAttribute('href')); + $this->assertEquals($site_name, $breadcrumbs[0]->getText()); // "Edit" tab does appear for data_set content type. $this->assertSession()->elementExists('xpath', '//a[@href = "/node/2/edit"]'); // "Outline" tab does not appear for data_set content type.