From a67bcc5f46f9b4eaa1ab7569643060adc6ff2638 Mon Sep 17 00:00:00 2001 From: Andy Broomfield Date: Thu, 24 Aug 2023 19:33:39 +0100 Subject: [PATCH 1/2] Disable the frontpage view on new installs Fix #549 for 3.x branch Disable the /node view --- localgov.install | 6 ++++++ tests/src/Functional/LocalGovProfileTest.php | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/localgov.install b/localgov.install index ee39b74..0a55015 100644 --- a/localgov.install +++ b/localgov.install @@ -6,6 +6,7 @@ */ use Drupal\user\Entity\User; +use Drupal\views\Entity\View; /** * Implements hook_install(). @@ -20,6 +21,11 @@ function localgov_install() { $user = User::load(1); $user->roles[] = 'administrator'; $user->save(); + + // Disable the frontpage view. + $frontpage_view = View::load('frontpage'); + $frontpage_view->setStatus(FALSE)->save(); + } /** diff --git a/tests/src/Functional/LocalGovProfileTest.php b/tests/src/Functional/LocalGovProfileTest.php index d1d3a4f..7b08d64 100644 --- a/tests/src/Functional/LocalGovProfileTest.php +++ b/tests/src/Functional/LocalGovProfileTest.php @@ -54,6 +54,10 @@ public function testLocalGovDrupalProfile() { $this->drupalLogin($adminUser); $this->drupalGet('admin'); $this->assertSession()->statusCodeEquals(Response::HTTP_OK); + + // Test that the /node view is disabled. + $this->drupalGet('/node'); + $this->assertSession()->statusCodeEquals(Response::HTTP_NOT_FOUND); } } From dbf078a2a9a0027c8b6a98ce4a1740b456d1a611 Mon Sep 17 00:00:00 2001 From: Andy Broomfield Date: Fri, 25 Aug 2023 11:07:07 +0100 Subject: [PATCH 2/2] Set the default front page to /user This is to allow a default accessible front page to exist on first install. --- localgov.install | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/localgov.install b/localgov.install index 0a55015..b78b971 100644 --- a/localgov.install +++ b/localgov.install @@ -26,6 +26,13 @@ function localgov_install() { $frontpage_view = View::load('frontpage'); $frontpage_view->setStatus(FALSE)->save(); + // Set front page to /user. + // This is so there is a default accessible front page on first install. + \Drupal::configFactory() + ->getEditable('system.site') + ->set('page.front', '/user') + ->save(); + } /**