Unverified Commit 6f247305 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #2883450 by mohit_aghera, Patrick Bauer, lauriii, corneboele, aarti...

Issue #2883450 by mohit_aghera, Patrick Bauer, lauriii, corneboele, aarti zikre, madhu_h, TBI, smustgrave, svdhout: Missing url prefix on language neutral content
parent 2d6ae27e
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -130,7 +130,10 @@ public function processOutbound($path, &$options = [], Request $request = NULL,
    }
    $languages = array_flip(array_keys($this->languageManager->getLanguages()));
    // Language can be passed as an option, or we go for current URL language.
    if (!isset($options['language'])) {
    if (!isset($options['language']) || ($options['language'] instanceof LanguageInterface && in_array($options['language']->getId(), [
      LanguageInterface::LANGCODE_NOT_SPECIFIED,
      LanguageInterface::LANGCODE_NOT_APPLICABLE,
    ]))) {
      $language_url = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL);
      $options['language'] = $language_url;
    }
+22 −0
Original line number Diff line number Diff line
@@ -577,4 +577,26 @@ public function testDetailsTitleIsNotEscaped() {
    $this->assertSession()->responseContains($markup);
  }

  /**
   * Test that when content is language neutral, it uses interface language.
   *
   * When language neutral content is displayed on interface language, it should
   * consider the interface language for creating the content link.
   */
  public function testUrlPrefixOnLanguageNeutralContent() {
    $this->drupalLogin($this->administrator);
    $neutral_langcodes = [
      LanguageInterface::LANGCODE_NOT_APPLICABLE,
      LanguageInterface::LANGCODE_NOT_SPECIFIED,
    ];
    foreach ($neutral_langcodes as $langcode) {
      $article = $this->drupalCreateNode(['type' => 'article', 'langcode' => $langcode]);
      $this->drupalGet("{$this->langcodes[1]}/admin/content");
      $this->assertSession()->linkByHrefExists("{$this->langcodes[1]}/node/{$article->id()}");

      $this->drupalGet("{$this->langcodes[2]}/admin/content");
      $this->assertSession()->linkByHrefExists("{$this->langcodes[2]}/node/{$article->id()}");
    }
  }

}