diff -u b/src/EventSubscriber/Fast404EventSubscriber.php b/src/EventSubscriber/Fast404EventSubscriber.php --- b/src/EventSubscriber/Fast404EventSubscriber.php +++ b/src/EventSubscriber/Fast404EventSubscriber.php @@ -27,7 +27,7 @@ public $requestStack; /** - * The language mananger + * The language manager. * * @var \Drupal\Core\Language\LanguageManagerInterface */ diff -u b/src/Fast404.php b/src/Fast404.php --- b/src/Fast404.php +++ b/src/Fast404.php @@ -41,7 +41,7 @@ public $loadHtml = TRUE; /** - * The langcode, this will help us to load the translated 404 page if it exists. + * The langcode to use for the translated 404 page if it exists. * * @var string */ @@ -213,13 +213,14 @@ // If a file is set to provide us with Fast 404 joy, load it. if (($this->loadHtml || Settings::get('fast404_HTML_error_all_paths', FALSE) === TRUE)) { if (is_array($custom_404)) { - // If it is an array, get path depending on the langcode, if langcode is NULL, default to the first value. + // For array, get path depending on the langcode; if langcode is NULL, default to the first value. $custom_404_path = $this->langcode && isset($custom_404[$this->langcode]) ? $custom_404[$this->langcode] : reset($custom_404); - } else { + } + else { $custom_404_path = $custom_404; } - if(file_exists($custom_404_path)) { + if (file_exists($custom_404_path)) { $message = @file_get_contents($custom_404_path, FALSE); } } reverted: --- b/tests/html/en.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - Not Found - - -

- Custom Page not found -

- - reverted: --- b/tests/html/fr.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - Pas trouvé - - -

- Page personnalisée introuvable -

- - reverted: --- b/tests/src/Functional/Fast404HtmlPageTest.php +++ /dev/null @@ -1,80 +0,0 @@ -save(); - } - - /** - * Tests the html page functionality. - */ - public function testHtmlPage() { - // Let fast404 subscribe to NotFoundHttpException - $settings['settings']['fast404_not_found_exception'] = (object) [ - 'value' => TRUE, - 'required' => TRUE, - ]; - - // Setup html page without translation. - $settings['settings']['fast404_HTML_error_page'] = (object) [ - 'value' => \Drupal::moduleHandler()->getModule('fast404')->getPath() . '/tests/html/en.html', - 'required' => TRUE, - ]; - - $this->writeSettings($settings); - - // Try to access a non-existant page. - $this->drupalGet('/unknown-page'); - $this->assertSession()->statusCodeEquals(404); - $this->assertSession()->pageTextContains('Custom Page not found'); - - // Setup html page with translation. - $settings['settings']['fast404_HTML_error_page'] = (object) [ - 'value' => [ - 'en' => \Drupal::moduleHandler()->getModule('fast404')->getPath() . '/tests/html/en.html', - 'fr' => \Drupal::moduleHandler()->getModule('fast404')->getPath() . '/tests/html/fr.html', - ], - 'required' => TRUE, - ]; - - $this->writeSettings($settings); - - // Try to access a non-existant page. - $this->drupalGet('/unknown-page-en'); - $this->assertSession()->statusCodeEquals(404); - $this->assertSession()->pageTextContains('Custom Page not found'); - - // Try to access a non-existant page. - $this->drupalGet('/fr/unknown-page-fr'); - $this->assertSession()->statusCodeEquals(404); - $this->assertSession()->pageTextContains('Page personnalisée introuvable'); - } -}