From 16ce6073c390980f0068c9a86bfeb7515a42d86f Mon Sep 17 00:00:00 2001
From: Lily Yan <l26yan@uwaterloo.ca>
Date: Thu, 16 Feb 2023 13:34:16 -0500
Subject: [PATCH] ISTWCMS-6076 Swap the order of the content author and content
 editor roles for the existing site

---
 uw_cfg_common.install | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/uw_cfg_common.install b/uw_cfg_common.install
index c5c52ba5..a2b1beee 100644
--- a/uw_cfg_common.install
+++ b/uw_cfg_common.install
@@ -708,3 +708,22 @@ function uw_cfg_common_update_9106(&$sandbox) {
     }
   }
 }
+
+/**
+ * Swap the order of content author and editor roles.
+ */
+function uw_cfg_common_update_9107(&$sandbox) {
+  // The original weight of content editor role is 5.
+  // The original weight of content author role is 4.
+  $role_ids = [
+    'uw_role_content_editor' => 4,
+    'uw_role_content_author' => 5,
+  ];
+  // Set new weight of content editor role as 4.
+  // Set new weight of content author role as 5.
+  foreach ($role_ids as $role_id => $weight) {
+    $role = Role::load($role_id);
+    $role->setWeight($weight);
+    $role->save();
+  }
+}
-- 
GitLab