From 96292f813cb367b738e88e36c73534c98b998bc8 Mon Sep 17 00:00:00 2001 From: Fran Garcia-Linares <fjgarlin@gmail.com> Date: Fri, 15 Nov 2024 09:53:49 +0100 Subject: [PATCH] New command to resync roles. --- src/Commands/DrushCommands.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Commands/DrushCommands.php b/src/Commands/DrushCommands.php index aa8d3a818..3f491213e 100644 --- a/src/Commands/DrushCommands.php +++ b/src/Commands/DrushCommands.php @@ -2,6 +2,7 @@ namespace Drupal\drupalorg\Commands; +use Drupal\Core\Site\Settings; use Drupal\drupalorg\Utilities\ActiveInstalls; use Drupal\drupalorg\Utilities\ComposerNamespace; use Drupal\drupalorg\Utilities\CoreCompatibility; @@ -80,4 +81,25 @@ class DrushCommands extends BaseDrushCommands { } } + /** + * This is a D10 role only which gets overwritten when a user is re-synced via migrations. + * + * @command drupalorg:fix-landing-page-administrator-role + * @usage drush drupalorg:fix-landing-page-administrator-role + */ + public function fixLandingPageAdministratorRoles() { + $allowed_users = Settings::get('drupalorg_allowed_users'); + if (is_array($allowed_users)) { + foreach ($allowed_users as $allowed_user) { + if ($allowed_user !== '*') { + $user = user_load_by_name($allowed_user); + if ($user) { + $user->addRole('landing_pages_administrator'); + $user->save(); + } + } + } + } + } + } -- GitLab