From e0a86b4b6515eb1dc2096f96a7c1e52db19fa8d8 Mon Sep 17 00:00:00 2001
From: Konstantinos Platis <konstantinos.platis@cern.ch>
Date: Thu, 6 May 2021 09:34:35 +0000
Subject: [PATCH 1/3] Add composer.json file

---
 composer.json | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 composer.json

diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..5196cda
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,20 @@
+{
+  "name": "drupal/cern-integration",
+  "description": "Custom functionality and constraints for CERN Drupal infrastructure",
+  "version": "8.0.9",
+  "type": "drupal-custom-module",
+  "license": "GPL-2.0-or-later",
+  "authors": [
+    {
+      "name": "Konstantinos Platis",
+      "email": "konstantinos.platis@cern.ch"
+    }
+  ],
+  "repositories": [
+    {
+      "type": "composer",
+      "url": "https://packages.drupal.org/8"
+    }
+  ],
+  "require": {}
+}
-- 
GitLab


From 0332fc0635bb5e5d3abad20b2786f71bfaf069b0 Mon Sep 17 00:00:00 2001
From: Konstantinos Platis <konstantinos.platis@cern.ch>
Date: Thu, 6 May 2021 12:39:22 +0200
Subject: [PATCH 2/3] Add d9 support (passes d9 upgrade status check)

---
 cern_integration.info.yml            | 1 +
 cern_integration.install             | 4 ++--
 cern_integration.module              | 6 +++---
 src/Controller/BackendController.php | 2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/cern_integration.info.yml b/cern_integration.info.yml
index d1813d2..f65b30b 100644
--- a/cern_integration.info.yml
+++ b/cern_integration.info.yml
@@ -4,5 +4,6 @@ package: CERN
 type: module
 version: '8.0.9'
 core: 8.x
+core_version_requirement: ^8 || ^9
 
 required: TRUE
diff --git a/cern_integration.install b/cern_integration.install
index 7ccb43d..85bd273 100644
--- a/cern_integration.install
+++ b/cern_integration.install
@@ -2,9 +2,9 @@
 
 
 function cern_integration_install() {
-  drupal_set_message(t('CERN Integration module installed successfully.'));
+  \Drupal::messenger()->addMessage(t('CERN Integration module installed successfully.'));
 }
 
 function cern_integration_uninstall() {
-  drupal_set_message(t('CERN Integration module was uninstalled successfully.'));
+  \Drupal::messenger()->addMessage(t('CERN Integration module was uninstalled successfully.'));
 }
diff --git a/cern_integration.module b/cern_integration.module
index d3906e0..5c31320 100644
--- a/cern_integration.module
+++ b/cern_integration.module
@@ -43,7 +43,7 @@ function cern_integration_update_projects_alter(&$projects)
     // unset($projects['drupal']);
 
     // Remove all centrally managed modules.
-    foreach (system_get_info("module") as $module_name => $module) {
+    foreach (\Drupal::service('extension.list.module')->getExtensionInfo() as $module_name => $module) {
         if (preg_match('#^modules/#', drupal_get_path("module", $module_name))) {
             if (isset($module["project"])){
                 unset($projects[$module["project"]]);
@@ -52,7 +52,7 @@ function cern_integration_update_projects_alter(&$projects)
     }
 
     // Remove all centrally managed themes.
-    foreach (system_get_info("theme") as $theme_name => $theme) {
+    foreach (\Drupal::service('extension.list.theme')->getExtensionInfo() as $theme_name => $theme) {
         if (preg_match('#^themes/#', drupal_get_path("theme", $theme_name))) {
             if (isset($theme["project"])){
                 unset($projects[$theme["project"]]);
@@ -91,7 +91,7 @@ function cern_integration_form_views_form_user_admin_people_page_1_alter(&$form,
 *  Disable fields under admin/people/create
 */
 function cern_integration_form_user_register_form_alter(&$form, &$form_state, $form_id){
-    drupal_set_message(t("Adding/Removing users is DISABLED."),"warning");
+    \Drupal::messenger()->addMessage(t("Adding/Removing users is DISABLED."),"warning");
     // Disable all elements from this form.
     foreach (\Drupal\Core\Render\Element::children($form) as $key) {
         $form[$key]['#disabled'] = TRUE;
diff --git a/src/Controller/BackendController.php b/src/Controller/BackendController.php
index 5493b42..486c86e 100644
--- a/src/Controller/BackendController.php
+++ b/src/Controller/BackendController.php
@@ -13,7 +13,7 @@ class BackendController extends ControllerBase {
   /**
    * Returns a render-able array for a test page.
    */
-  public function redirect() {
+  public function redirect($route_name, array $route_parameters = [], array $options = [], $status = 302) {
      return new RedirectResponse("/_site");
   }
 
-- 
GitLab


From 961f4f0069fb56df17caed16796205e322673390 Mon Sep 17 00:00:00 2001
From: Konstantinos Platis <konstantinos.platis@cern.ch>
Date: Thu, 6 May 2021 14:53:47 +0200
Subject: [PATCH 3/3] Replace getExtensionInfo with getAllInstalledInfo

---
 cern_integration.module | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cern_integration.module b/cern_integration.module
index 5c31320..25dc6b2 100644
--- a/cern_integration.module
+++ b/cern_integration.module
@@ -43,7 +43,7 @@ function cern_integration_update_projects_alter(&$projects)
     // unset($projects['drupal']);
 
     // Remove all centrally managed modules.
-    foreach (\Drupal::service('extension.list.module')->getExtensionInfo() as $module_name => $module) {
+    foreach (\Drupal::service('extension.list.module')->getAllInstalledInfo() as $module_name => $module) {
         if (preg_match('#^modules/#', drupal_get_path("module", $module_name))) {
             if (isset($module["project"])){
                 unset($projects[$module["project"]]);
@@ -52,7 +52,7 @@ function cern_integration_update_projects_alter(&$projects)
     }
 
     // Remove all centrally managed themes.
-    foreach (\Drupal::service('extension.list.theme')->getExtensionInfo() as $theme_name => $theme) {
+    foreach (\Drupal::service('extension.list.theme')->getAllInstalledInfo() as $theme_name => $theme) {
         if (preg_match('#^themes/#', drupal_get_path("theme", $theme_name))) {
             if (isset($theme["project"])){
                 unset($projects[$theme["project"]]);
-- 
GitLab