From e8597750d0999a3ac9cebb53b8c865d99de2f4d1 Mon Sep 17 00:00:00 2001
From: Blas Oliva <blasoliva@gmail.com>
Date: Wed, 14 May 2025 11:56:31 -0300
Subject: [PATCH 1/3] Drupal 11 compatibility fixes

---
 src/Form/SwitchPageThemeSettingForm.php | 9 ++++++++-
 switch_page_theme.info.yml              | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/Form/SwitchPageThemeSettingForm.php b/src/Form/SwitchPageThemeSettingForm.php
index 4e84c7d..f1eb084 100755
--- a/src/Form/SwitchPageThemeSettingForm.php
+++ b/src/Form/SwitchPageThemeSettingForm.php
@@ -2,11 +2,14 @@
 
 namespace Drupal\switch_page_theme\Form;
 
+use Drupal\Component\Utility\Html;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Language\LanguageManagerInterface;
 use Drupal\domain\DomainStorageInterface;
+use Drupal\user\Entity\Role;
+use Drupal\user\RoleInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Extension\ThemeHandlerInterface;
@@ -247,11 +250,15 @@ class SwitchPageThemeSettingForm extends ConfigFormBase {
         '#default_value' => isset($value['theme']) ? $value['theme'] : [],
       ];
 
+      $roles = Role::loadMultiple();
+      unset($roles[RoleInterface::ANONYMOUS_ID]);
+      $roles = array_map(fn(RoleInterface $role) => Html::escape($role->label()), $roles);
+ 
       $form['spt_table'][$i]['roles'] = [
         '#type' => 'checkboxes',
         '#title' => $this->t('Roles'),
         '#title_display' => 'invisible',
-        '#options' => user_role_names(),
+        '#options' => $roles,
         '#default_value' => isset($value['roles']) ? $value['roles'] : [],
       ];
 
diff --git a/switch_page_theme.info.yml b/switch_page_theme.info.yml
index 298d4a3..60aeb09 100644
--- a/switch_page_theme.info.yml
+++ b/switch_page_theme.info.yml
@@ -2,7 +2,7 @@ name: Switch Page Theme
 description: 'Switches active theme on specific pages.'
 package: User Interface
 type: module
-core_version_requirement: ^8 || ^9 || ^10
+core_version_requirement: ^10 || ^11
 configure: switch_page_theme.settings
 dependencies:
   - drupal:path_alias
\ No newline at end of file
-- 
GitLab


From 2ce11bcb526f6abedb6700c2d40ae37edbf95547 Mon Sep 17 00:00:00 2001
From: Kirill Semihin <22680-ksemihin@users.noreply.drupalcode.org>
Date: Tue, 2 Sep 2025 07:44:19 +0000
Subject: [PATCH 2/3] Issue #3489081: Add composer.json file

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

diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..06d4940
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,11 @@
+{
+  "name": "drupal/switch_page_theme",
+  "description": "Switches active theme on specific pages.",
+  "type": "drupal-module",
+  "homepage": "http://drupal.org/project/switch_page_theme",
+  "license": "GPL-2.0-or-later",
+  "support": {
+    "issues": "https://www.drupal.org/project/issues/switch_page_theme",
+    "source": "https://git.drupalcode.org/project/switch_page_theme"
+  }
+}
-- 
GitLab


From 0ca9966f5cf506df8c5d1c387e473915fdaa562f Mon Sep 17 00:00:00 2001
From: Bernard Munslow <bernardmunslow@gmail.com>
Date: Thu, 30 Oct 2025 10:35:13 +0100
Subject: [PATCH 3/3] Avoid overriding constructor in
 SwitchPageThemeSettingForm

This was needed to fix issue:

`Too few arguments to function Drupal\Core\Form\ConfigFormBase::__construct()`

@see https://www.drupal.org/about/core/policies/core-change-policies/bc-policy#constructors
---
 src/Form/SwitchPageThemeSettingForm.php | 49 ++++---------------------
 1 file changed, 7 insertions(+), 42 deletions(-)

diff --git a/src/Form/SwitchPageThemeSettingForm.php b/src/Form/SwitchPageThemeSettingForm.php
index f1eb084..013cde2 100755
--- a/src/Form/SwitchPageThemeSettingForm.php
+++ b/src/Form/SwitchPageThemeSettingForm.php
@@ -47,51 +47,16 @@ class SwitchPageThemeSettingForm extends ConfigFormBase {
    */
   protected $themeHandler;
 
-  /**
-   * Construct function.
-   *
-   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
-   *   The config factory load.
-   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
-   *   The module handler.
-   * @param \Drupal\domain\DomainLoader $domain_loader
-   *   The domain loader.
-   * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
-   *   The language manager service.
-   * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
-   *   The theme handler.
-   */
-  public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, DomainStorageInterface $domain_storage = NULL, LanguageManagerInterface $language_manager = NULL, ThemeHandlerInterface $theme_handler = NULL) {
-    parent::__construct($config_factory);
-    $this->moduleHandler = $module_handler;
-    if ($domain_storage) {
-      $this->domainStorage = $domain_storage;
-    }
-    if ($language_manager) {
-      $this->languageManager = $language_manager;
-    }
-    $this->themeHandler = $theme_handler;
-  }
-
   /**
    * {@inheritdoc}
    */
   public static function create(ContainerInterface $container) {
-    $domainServices = NULL;
-    $languageServices = NULL;
-    if ($container->has('domain.negotiator')) {
-      $domainServices = $container->get('entity_type.manager')->getStorage('domain');
-    }
-    if ($container->has('language_manager')) {
-      $languageServices = $container->get('language_manager');
-    }
-    return new static(
-      $container->get('config.factory'),
-      $container->get('module_handler'),
-      $domainServices,
-      $languageServices,
-      $container->get('theme_handler')
-    );
+    $instance = parent::create($container);
+    $instance->moduleHandler = $container->get('module_handler');
+    $instance->domainStorage = $container->has('domain.negotiator') ? $container->get('entity_type.manager')->getStorage('domain') : NULL;
+    $instance->languageManager = $container->has('language_manager') ? $container->get('language_manager') : NULL;
+    $instance->themeHandler = $container->get('theme_handler');
+    return $instance;
   }
 
   /**
@@ -253,7 +218,7 @@ class SwitchPageThemeSettingForm extends ConfigFormBase {
       $roles = Role::loadMultiple();
       unset($roles[RoleInterface::ANONYMOUS_ID]);
       $roles = array_map(fn(RoleInterface $role) => Html::escape($role->label()), $roles);
- 
+
       $form['spt_table'][$i]['roles'] = [
         '#type' => 'checkboxes',
         '#title' => $this->t('Roles'),
-- 
GitLab

