Loading src/EventSubscriber/StaticRootPageSubscriber.php +3 −3 Changes for src/EventSubscriber/StaticRootPageSubscriber.php: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ class StaticRootPageSubscriber implements EventSubscriberInterface { /** * The event. * * @var \Symfony\Component\HttpKernel\Event\FilterResponseEvent * @var \Symfony\Component\HttpKernel\Event\ResponseEvent */ protected $event; Loading Loading @@ -69,13 +69,13 @@ class StaticRootPageSubscriber implements EventSubscriberInterface { /** * Event callback. * * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event * @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event * The event object. * * @return bool * Returns FALSE. */ public function redirectToStaticRootPage(FilterResponseEvent $event) { public function redirectToStaticRootPage(\Symfony\Component\HttpKernel\Event\ResponseEvent $event) { $this->event = $event; if ($this->languageNegotiator->isNegotiationMethodEnabled('static-root-page') && $this->requestStack->getCurrentRequest()->getRequestUri() === $this->requestStack->getCurrentRequest()->getBaseUrl() . '/') { Loading static_root_page.info.yml +1 −2 Changes for static_root_page.info.yml: 1 added line, 2 removed lines. Original line number Diff line number Diff line Loading @@ -5,6 +5,5 @@ dependencies: - drupal:locale - drupal:content_translation configure: language.negotiation core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^9.1 || ^10 type: module tests/src/Functional/StaticRootPageTest.php +15 −8 Changes for tests/src/Functional/StaticRootPageTest.php: 15 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -40,29 +40,34 @@ class StaticRootPageTest extends BrowserTestBase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $admin = $this->drupalCreateUser([], NULL, TRUE); $this->drupalLogin($admin); $this->drupalGet('/admin/config/regional/translate/settings'); // Disable translation download. $this->drupalPostForm('/admin/config/regional/translate/settings', [ $this->submitForm([ 'use_source' => 'local', ], 'Save configuration'); $this->drupalGet('/admin/config/regional/language/add'); // Create FR. $this->drupalPostForm('/admin/config/regional/language/add', [ $this->submitForm([ 'predefined_langcode' => 'fr', ], 'Add language'); $this->drupalGet('/admin/config/regional/language/detection/url'); // Set prefixes to en and fr. $this->drupalPostForm('/admin/config/regional/language/detection/url', [ $this->submitForm([ 'prefix[en]' => 'en', 'prefix[fr]' => 'fr', ], 'Save configuration'); $this->drupalGet('/admin/config/regional/language/detection'); // Set up URL and language selection page methods. $this->drupalPostForm('/admin/config/regional/language/detection', [ $this->submitForm([ 'language_interface[enabled][language-url]' => TRUE, ], 'Save settings'); $this->drupalGet('/admin/structure/types/add'); // Create content type. $this->drupalPostForm('/admin/structure/types/add', [ $this->submitForm([ 'name' => 'Page', 'type' => 'page', 'language_configuration[content_translation]' => TRUE, Loading @@ -74,7 +79,8 @@ class StaticRootPageTest extends BrowserTestBase { * Test the "language prefixes" condition with Static root page disabled. */ public function testDisabledModule() { $this->drupalPostForm('/admin/config/regional/language/detection', [ $this->drupalGet('/admin/config/regional/language/detection'); $this->submitForm([ 'language_interface[enabled][static-root-page]' => FALSE, 'language_interface[enabled][language-url]' => TRUE, ], 'Save settings'); Loading @@ -93,7 +99,8 @@ class StaticRootPageTest extends BrowserTestBase { * Test the "language prefixes" condition with Static root page enabled. */ public function testEnabledModule() { $this->drupalPostForm('/admin/config/regional/language/detection', [ $this->drupalGet('/admin/config/regional/language/detection'); $this->submitForm([ 'language_interface[enabled][static-root-page]' => TRUE, 'language_interface[enabled][language-url]' => TRUE, ], 'Save settings'); Loading Loading
src/EventSubscriber/StaticRootPageSubscriber.php +3 −3 Changes for src/EventSubscriber/StaticRootPageSubscriber.php: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ class StaticRootPageSubscriber implements EventSubscriberInterface { /** * The event. * * @var \Symfony\Component\HttpKernel\Event\FilterResponseEvent * @var \Symfony\Component\HttpKernel\Event\ResponseEvent */ protected $event; Loading Loading @@ -69,13 +69,13 @@ class StaticRootPageSubscriber implements EventSubscriberInterface { /** * Event callback. * * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event * @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event * The event object. * * @return bool * Returns FALSE. */ public function redirectToStaticRootPage(FilterResponseEvent $event) { public function redirectToStaticRootPage(\Symfony\Component\HttpKernel\Event\ResponseEvent $event) { $this->event = $event; if ($this->languageNegotiator->isNegotiationMethodEnabled('static-root-page') && $this->requestStack->getCurrentRequest()->getRequestUri() === $this->requestStack->getCurrentRequest()->getBaseUrl() . '/') { Loading
static_root_page.info.yml +1 −2 Changes for static_root_page.info.yml: 1 added line, 2 removed lines. Original line number Diff line number Diff line Loading @@ -5,6 +5,5 @@ dependencies: - drupal:locale - drupal:content_translation configure: language.negotiation core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^9.1 || ^10 type: module
tests/src/Functional/StaticRootPageTest.php +15 −8 Changes for tests/src/Functional/StaticRootPageTest.php: 15 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -40,29 +40,34 @@ class StaticRootPageTest extends BrowserTestBase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $admin = $this->drupalCreateUser([], NULL, TRUE); $this->drupalLogin($admin); $this->drupalGet('/admin/config/regional/translate/settings'); // Disable translation download. $this->drupalPostForm('/admin/config/regional/translate/settings', [ $this->submitForm([ 'use_source' => 'local', ], 'Save configuration'); $this->drupalGet('/admin/config/regional/language/add'); // Create FR. $this->drupalPostForm('/admin/config/regional/language/add', [ $this->submitForm([ 'predefined_langcode' => 'fr', ], 'Add language'); $this->drupalGet('/admin/config/regional/language/detection/url'); // Set prefixes to en and fr. $this->drupalPostForm('/admin/config/regional/language/detection/url', [ $this->submitForm([ 'prefix[en]' => 'en', 'prefix[fr]' => 'fr', ], 'Save configuration'); $this->drupalGet('/admin/config/regional/language/detection'); // Set up URL and language selection page methods. $this->drupalPostForm('/admin/config/regional/language/detection', [ $this->submitForm([ 'language_interface[enabled][language-url]' => TRUE, ], 'Save settings'); $this->drupalGet('/admin/structure/types/add'); // Create content type. $this->drupalPostForm('/admin/structure/types/add', [ $this->submitForm([ 'name' => 'Page', 'type' => 'page', 'language_configuration[content_translation]' => TRUE, Loading @@ -74,7 +79,8 @@ class StaticRootPageTest extends BrowserTestBase { * Test the "language prefixes" condition with Static root page disabled. */ public function testDisabledModule() { $this->drupalPostForm('/admin/config/regional/language/detection', [ $this->drupalGet('/admin/config/regional/language/detection'); $this->submitForm([ 'language_interface[enabled][static-root-page]' => FALSE, 'language_interface[enabled][language-url]' => TRUE, ], 'Save settings'); Loading @@ -93,7 +99,8 @@ class StaticRootPageTest extends BrowserTestBase { * Test the "language prefixes" condition with Static root page enabled. */ public function testEnabledModule() { $this->drupalPostForm('/admin/config/regional/language/detection', [ $this->drupalGet('/admin/config/regional/language/detection'); $this->submitForm([ 'language_interface[enabled][static-root-page]' => TRUE, 'language_interface[enabled][language-url]' => TRUE, ], 'Save settings'); Loading