From 322d65ca4ad5f70d9ff9b7764fdf83abc0b3c80b Mon Sep 17 00:00:00 2001
From: Chris Green <chrisgreen@arizona.edu>
Date: Wed, 22 Jan 2025 13:53:08 -0700
Subject: [PATCH 1/2] Issue #3501555 Address PHPCS failing test and set
 repository to not allow merging of merge requests with code that fails the
 PHPCS test.

---
 .gitlab-ci.yml                                    |  2 ++
 README.md                                         |  4 ++--
 src/EasyBreadcrumbBuilder.php                     |  2 ++
 src/TitleResolver.php                             |  3 ++-
 .../easy_breadcrumb_test.routing.yml              |  1 +
 tests/src/Kernel/EasyBreadcrumbBuilderTest.php    | 15 ++++++++++-----
 6 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 239fa18..09fac16 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -102,6 +102,8 @@ include:
 #
 cspell:
   allow_failure: false
+phpcs:
+  allow_failure: false
 phpstan:
   allow_failure: false
 eslint:
diff --git a/README.md b/README.md
index ae747c1..cab1876 100644
--- a/README.md
+++ b/README.md
@@ -5,8 +5,8 @@ the current page title in the breadcrumb. The module also comes with additional
 settings that are common features needed in breadcrumbs.
 
 Breadcrumbs use the current URL (path alias) and the current page title to
-build the crumbs. The module is designed to work out of the box with no adjustments,
-and it comes with settings to customize the crumbs.
+build the crumbs. The module is designed to work out of the box with no
+adjustments, and it comes with settings to customize the crumbs.
 
 For a full description of the module, visit the
 [project page](https://www.drupal.org/project/easy_breadcrumb).
diff --git a/src/EasyBreadcrumbBuilder.php b/src/EasyBreadcrumbBuilder.php
index 8f143f6..2e0c152 100644
--- a/src/EasyBreadcrumbBuilder.php
+++ b/src/EasyBreadcrumbBuilder.php
@@ -951,10 +951,12 @@ class EasyBreadcrumbBuilder implements BreadcrumbBuilderInterface {
       $redirect = NULL;
       try {
         // Ignore DI recommendation as we want no dependency on redirect module.
+        // phpcs:disable
         // @phpstan-ignore-next-line
         $redirect = \Drupal::service('redirect.repository')
           ->findMatchingRedirect($redirect_path, [], $this->languageManager->getCurrentLanguage()
             ->getId());
+        // phpcs:enable
       }
       catch (\Exception $exception) {
         // Do nothing for now.
diff --git a/src/TitleResolver.php b/src/TitleResolver.php
index fbe270b..adbf09e 100644
--- a/src/TitleResolver.php
+++ b/src/TitleResolver.php
@@ -71,7 +71,7 @@ class TitleResolver extends ControllerTitleResolver {
   public function getTitle(Request $request, Route $route) {
     $url = Url::fromUri("internal:" . $request->getRequestUri());
     $alternative_title_field = $this->config->get(EasyBreadcrumbConstants::ALTERNATIVE_TITLE_FIELD);
-    // If an alternative title field is set, load the entity if present and use that field.
+    // If an alternative title field is set, use it.
     if ($alternative_title_field) {
       $entity = NULL;
       try {
@@ -101,4 +101,5 @@ class TitleResolver extends ControllerTitleResolver {
 
     return parent::getTitle($request, $route);
   }
+
 }
diff --git a/tests/modules/easy_breadcrumb_test/easy_breadcrumb_test.routing.yml b/tests/modules/easy_breadcrumb_test/easy_breadcrumb_test.routing.yml
index d857a1f..a9054f0 100644
--- a/tests/modules/easy_breadcrumb_test/easy_breadcrumb_test.routing.yml
+++ b/tests/modules/easy_breadcrumb_test/easy_breadcrumb_test.routing.yml
@@ -26,6 +26,7 @@ easy_breadcrumb_test.title_render_array:
 easy_breadcrumb_test.custom_path:
   path: '/test/easy-breadcrumb-custom-path'
   requirements:
+    # This is a test route, so we allow all access.
     _access: 'TRUE'
   defaults:
     _title: 'Easy Breadcrumb Custom Path Test'
diff --git a/tests/src/Kernel/EasyBreadcrumbBuilderTest.php b/tests/src/Kernel/EasyBreadcrumbBuilderTest.php
index 8dc1408..42ca74e 100644
--- a/tests/src/Kernel/EasyBreadcrumbBuilderTest.php
+++ b/tests/src/Kernel/EasyBreadcrumbBuilderTest.php
@@ -228,13 +228,15 @@ class EasyBreadcrumbBuilderTest extends KernelTestBase {
     $this->assertEquals('base:part-1', $result->getLinks()[0]->getUrl()->toUriString());
   }
 
-    /**
-   * Tests a custom path override with title replacement and an unrouted url. (Issue #3271576)
+  /**
+   * Tests a custom path override with title replacement and an unrouted url.
+   *
+   * @see https://drupal.org/i/3271576
    */
   public function testCustomPathWithTitleAndUnroutedUrl() {
     \Drupal::configFactory()->getEditable(EasyBreadcrumbConstants::MODULE_SETTINGS)
       ->set(EasyBreadcrumbConstants::CUSTOM_PATHS, 'regex!/test/.+ :: Part 1 | /part-1 :: <title>')
-      ->set(EasyBreadcrumbConstants::TITLE_FROM_PAGE_WHEN_AVAILABLE, true)
+      ->set(EasyBreadcrumbConstants::TITLE_FROM_PAGE_WHEN_AVAILABLE, TRUE)
       ->save();
 
     $request = Request::create('/test/easy-breadcrumb-custom-path');
@@ -269,12 +271,14 @@ class EasyBreadcrumbBuilderTest extends KernelTestBase {
   }
 
   /**
-   * Tests a custom path override with title replacement and a route match. (Issue #3271576)
+   * Tests a custom path override with title replacement and a route match.
+   *
+   * @see https://drupal.org/i/3271576
    */
   public function testCustomPathWithTitleAndRoutedUrl() {
     \Drupal::configFactory()->getEditable(EasyBreadcrumbConstants::MODULE_SETTINGS)
       ->set(EasyBreadcrumbConstants::CUSTOM_PATHS, 'regex!/test/.+ :: Part 1 | /part-1 :: <title>')
-      ->set(EasyBreadcrumbConstants::TITLE_FROM_PAGE_WHEN_AVAILABLE, true)
+      ->set(EasyBreadcrumbConstants::TITLE_FROM_PAGE_WHEN_AVAILABLE, TRUE)
       ->save();
 
     $route_name = 'easy_breadcrumb_test.custom_path';
@@ -310,4 +314,5 @@ class EasyBreadcrumbBuilderTest extends KernelTestBase {
     $this->assertEquals('Easy Breadcrumb Custom Path Test', $result->getLinks()[1]->getText());
     $this->assertEquals('route:<none>', $result->getLinks()[1]->getUrl()->toUriString());
   }
+
 }
-- 
GitLab


From 86daea1f74584476eff4a6aae84a82a4b58be2a5 Mon Sep 17 00:00:00 2001
From: Sven Decabooter <sdecabooter@gmail.com>
Date: Wed, 12 Mar 2025 15:59:02 +0100
Subject: [PATCH 2/2] Fix missing newline at end of file

---
 easy_breadcrumb.install | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/easy_breadcrumb.install b/easy_breadcrumb.install
index aa72f3e..25de44d 100644
--- a/easy_breadcrumb.install
+++ b/easy_breadcrumb.install
@@ -150,4 +150,4 @@ function easy_breadcrumb_update_8009() {
     $config->save(TRUE);
     return t('Breadcrumb segment minimum count has been set to 1 to maintain the existing behavior when rendering breadcrumbs.');
   }
-}
\ No newline at end of file
+}
-- 
GitLab