Commit 3417d788 authored by surgemartin's avatar surgemartin Committed by Greg Boggs
Browse files

Issue #3161100 by Ahmad Smhan, i.mcbride, mandclu, Greg Boggs,...

Issue #3161100 by Ahmad Smhan, i.mcbride, mandclu, Greg Boggs, jennypanighetti, amklose, johnhelmuth, Antoniya, mikemccaffrey: Allow hyphen and underscore in breadcrumb links from titles and menus
parent 59038c28
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -581,7 +581,7 @@ class EasyBreadcrumbBuilder implements BreadcrumbBuilderInterface {
            // Fallback to using the raw path component as the title if the
            // route is missing a _title or _title_callback attribute.
            if (!isset($title)) {
              $title = $this->normalizeText(end($path_elements));
              $title = $this->normalizeText(str_replace(['-', '_'], ' ', end($path_elements)));
              if (array_key_exists($title, $replacedTitles)) {
                $title = $replacedTitles[$title];
              }
@@ -623,7 +623,7 @@ class EasyBreadcrumbBuilder implements BreadcrumbBuilderInterface {
        }
      }
      elseif ($this->config->get(EasyBreadcrumbConstants::INCLUDE_INVALID_PATHS) && empty($exclude[implode('/', $path_elements)])) {
        $title = $this->normalizeText(end($path_elements));
        $title = $this->normalizeText(str_replace(['-', '_'], ' ', end($path_elements)));
        $this->applyTitleReplacement($title, $replacedTitles);
        $links[] = Link::createFromRoute($title, '<none>');
        unset($title);
@@ -933,8 +933,7 @@ class EasyBreadcrumbBuilder implements BreadcrumbBuilderInterface {
    }

    // Transform '-hello--world_javascript-' to 'hello world javascript'.
    $normalized_text = str_replace(['-', '_'], ' ', $raw_text);
    $normalized_text = trim($normalized_text);
    $normalized_text = trim($raw_text);
    $normalized_text = preg_replace('/\s{2,}/', ' ', $normalized_text);

    // Gets the flag saying the capitalizator mode.