Commit 42f700bd authored by George's avatar George
Browse files

Issue #3172114 by geoanders: For multilingual sites path `/en/node` is still enabled.

parent 83cb83ab
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ class RedirectNodeRouteSubscriber implements EventSubscriberInterface {
   *   The GetResponseEvent to process.
   */
  public function redirectNodeUrl(GetResponseEvent $event) {

    $config = $this->configFactory->get('system.site');
    $pageSlashNode = $config->get('site_disable_page_node');

@@ -61,19 +60,23 @@ class RedirectNodeRouteSubscriber implements EventSubscriberInterface {

      $request = $event->getRequest();
      $getRequestUri = $request->getRequestUri();
      $getLanguage = $this->languageManager->getCurrentLanguage();
      $validUris = [
        '/node',
        '/' . $getLanguage->getId() . '/node',
      ];

      if ($getRequestUri === '/node') {
      // Check Uri to see if it's valid for processing
      if (in_array($getRequestUri, $validUris)) {

        $options = [];

        if ($this->languageManager->isMultilingual()) {
          $getLanguage = $this->languageManager->getCurrentLanguage();
          $options = ['language' => $getLanguage];
        }

        $pageSlashNode404 = $config->get('site_disable_page_node_404');
        if ($pageSlashNode404) {
          // only return a response for a master request
          // Only return a response for a master request
          if ($event->isMainRequest()) {
            throw new NotFoundHttpException();
          }
@@ -83,7 +86,6 @@ class RedirectNodeRouteSubscriber implements EventSubscriberInterface {
          $response = new RedirectResponse($url->toString());
          $response->send();
        }

      }
    }
  }