Skip to content
Snippets Groups Projects
Commit 322d65ca authored by Chris Green's avatar Chris Green Committed by Sven Decabooter
Browse files

Issue #3501555 Address PHPCS failing test and set repository to not allow...

Issue #3501555 Address PHPCS failing test and set repository to not allow merging of merge requests with code that fails the PHPCS test.
parent d14791ba
No related branches found
No related tags found
1 merge request!143Issue #3501555 Address PHPCS failing test and set repository to not allow merging of merge requests with code that fails the PHPCS test.
......@@ -102,6 +102,8 @@ include:
#
cspell:
allow_failure: false
phpcs:
allow_failure: false
phpstan:
allow_failure: false
eslint:
......
......@@ -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).
......
......@@ -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.
......
......@@ -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);
}
}
......@@ -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'
......
......@@ -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());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment