Skip to content

Adds and configures redirect module #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"drupal/gin_login": "^2.0",
"drupal/gin_toolbar": "^1.0@RC",
"drupal/metatag": "^1.22",
"drupal/redirect": "^1.9",
"localgovdrupal/localgov_blogs": "^1.0.0-beta3",
"localgovdrupal/localgov_core": "^2.12",
"localgovdrupal/localgov_directories": "^3.0@alpha",
Expand Down
1 change: 1 addition & 0 deletions localgov_microsites.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ install:
- metatag:metatag_open_graph
- metatag:metatag_twitter_cards
- require_login:require_login
- redirect:redirect
- twig_tweak:twig_tweak

# LocalGov Drupal
Expand Down
44 changes: 43 additions & 1 deletion localgov_microsites.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,54 @@
* Install functions for the LocalGov Microsites installation profile.
*/

use Drupal\user\Entity\Role;

/**
* Implements hook_install().
*/
function localgov_microsites_install() {
// Allow microsites controllers and editors to use redirect module.
$role_names = [
'microsites_controller',
'microsites_trusted_editor',
];

// Set 'administer redirects' permission for controllers and editors.
foreach ($role_names as $role_name) {
$role = Role::load($role_name);
$role->grantPermission('administer redirects');
$role->save();
}
}

/**
* Enable stable9 theme if localgov_base theme is enabled.
*/
function localgov_update_9501() {

if (\Drupal::service('theme_handler')->themeExists('localgov_base')) {
\Drupal::service('theme_installer')->install(['stable9']);
}
}

/**
* Enable redirect module and set 'administer redirects' permission.
*/
function localgov_microsites_update_10001() {
// Enable redirect module if it is not already enabled.
$moduleHandler = \Drupal::service('module_handler');
if (!$moduleHandler->moduleExists('redirect')) {
\Drupal::service('module_installer')->install(['redirect']);
}

// Set 'administer redirects' permission for controllers and editors.
$role_names = [
'microsites_controller',
'microsites_trusted_editor',
];

foreach ($role_names as $role_name) {
$role = Role::load($role_name);
$role->grantPermission('administer redirects');
$role->save();
}
}
Loading