Skip to content

Commit

Permalink
Merge pull request #612 from localgovdrupal/feature/3.x-549-disable-n…
Browse files Browse the repository at this point in the history
…ode-view

[3.x] Disable the frontpage view on new installs
  • Loading branch information
andybroomfield authored Sep 4, 2023
2 parents 04ea98d + dbf078a commit d66cfdc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions localgov.install
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

use Drupal\user\Entity\User;
use Drupal\views\Entity\View;

/**
* Implements hook_install().
Expand All @@ -20,6 +21,18 @@ 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();

// 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();

}

/**
Expand Down
4 changes: 4 additions & 0 deletions tests/src/Functional/LocalGovProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}

0 comments on commit d66cfdc

Please sign in to comment.