Commit 89a989ac authored by Omkar Deshpande's avatar Omkar Deshpande Committed by Greg Boggs
Browse files

Issue #3249447 by omkar-pd, 3li, Greg Boggs, W01F: Option to Remove repeated...

Issue #3249447 by omkar-pd, 3li, Greg Boggs, W01F: Option to Remove repeated identical segments by text only
parent 55d62afb
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -817,7 +817,8 @@ class EasyBreadcrumbBuilder implements BreadcrumbBuilderInterface {
      $links_equal = FALSE;
    }

    if ($link1->getUrl()->getInternalPath() != $link2->getUrl()->getInternalPath()) {
    $validate_urls = $this->config->get(EasyBreadcrumbConstants::REMOVE_REPEATED_SEGMENTS_TEXT_ONLY);
    if (!$validate_urls && ($link1->getUrl()->getInternalPath() != $link2->getUrl()->getInternalPath())) {
      $links_equal = FALSE;
    }

+5 −0
Original line number Diff line number Diff line
@@ -136,6 +136,11 @@ class EasyBreadcrumbConstants {
   */
  const REMOVE_REPEATED_SEGMENTS = 'remove_repeated_segments';

  /**
   * Flag for removing repeated identical segments from the breadcrumb ignoring url information.
   */
  const REMOVE_REPEATED_SEGMENTS_TEXT_ONLY = 'remove_repeated_segments_text_only';

  /**
   * Flag for storing absolute path settings.
   */
+12 −0
Original line number Diff line number Diff line
@@ -78,6 +78,18 @@ class EasyBreadcrumbGeneralSettingsForm extends ConfigFormBase {
      '#default_value' => $config->get(EasyBreadcrumbConstants::REMOVE_REPEATED_SEGMENTS),
    ];

    $details_general[EasyBreadcrumbConstants::REMOVE_REPEATED_SEGMENTS_TEXT_ONLY] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Remove repeated identical segments - only validate on the text'),
      '#description' => $this->t('When removing identical segments only text is matched upon.'),
      '#default_value' => $config->get(EasyBreadcrumbConstants::REMOVE_REPEATED_SEGMENTS_TEXT_ONLY),
      '#states' => [
        'invisible' => [
          ':input[name="' . EasyBreadcrumbConstants::REMOVE_REPEATED_SEGMENTS . '"]' => ['checked' => FALSE],
        ],
      ],
    ];

    $details_general[EasyBreadcrumbConstants::INCLUDE_HOME_SEGMENT] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Include the front page as a segment in the breadcrumb'),