diff -u b/switch_page_theme.info.yml b/switch_page_theme.info.yml --- b/switch_page_theme.info.yml +++ b/switch_page_theme.info.yml @@ -3,6 +3,6 @@ package: User Interface type: module -core: 8.x core_version_requirement: ^8 || ^9 +core: 8.x configure: switch_page_theme.settings only in patch2: unchanged: --- a/src/Form/SwitchPageThemeSettingForm.php +++ b/src/Form/SwitchPageThemeSettingForm.php @@ -3,6 +3,7 @@ namespace Drupal\switch_page_theme\Form; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManagerInterface; @@ -21,6 +22,13 @@ class SwitchPageThemeSettingForm extends ConfigFormBase { */ protected $moduleHandler; + /** + * The theme handler. + * + * @var \Drupal\Core\Extension\ThemeHandlerInterface + */ + protected $themeHandler; + /** * The Domain loader. * @@ -38,8 +46,9 @@ class SwitchPageThemeSettingForm extends ConfigFormBase { /** * {@inheritdoc} */ - public function __construct(ModuleHandlerInterface $module_handler, DomainLoader $domain_loader = NULL, LanguageManagerInterface $language_manager = NULL) { + public function __construct(ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, DomainLoader $domain_loader = NULL, LanguageManagerInterface $language_manager = NULL) { $this->moduleHandler = $module_handler; + $this->themeHandler = $theme_handler; if ($domain_loader) { $this->domainLoader = $domain_loader; } @@ -62,6 +71,7 @@ class SwitchPageThemeSettingForm extends ConfigFormBase { } return new static( $container->get('module_handler'), + $container->get('theme_handler'), $domainServices, $languageServices ); @@ -143,7 +153,7 @@ class SwitchPageThemeSettingForm extends ConfigFormBase { ]; // Available themes. - $themes = system_list('theme'); + $themes = $this->themeHandler->listInfo(); $themeNames[''] = '--Select--'; foreach ($themes as $key => $value) { $themeNames[$key] = $value->info['name']; only in patch2: unchanged: --- a/src/Theme/PageThemeNegotiator.php +++ b/src/Theme/PageThemeNegotiator.php @@ -6,7 +6,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Path\CurrentPathStack; -use Drupal\Core\Path\AliasManagerInterface; +use Drupal\path_alias\AliasManagerInterface; use Drupal\Core\Path\PathMatcherInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountProxyInterface; @@ -36,7 +36,7 @@ class PageThemeNegotiator implements ThemeNegotiatorInterface { /** * Protected pathAlias variable. * - * @var Drupal\Core\Path\AliasManagerInterface + * @var Drupal\path_alias\AliasManagerInterface */ protected $pathAlias; only in patch2: unchanged: --- a/switch_page_theme.services.yml +++ b/switch_page_theme.services.yml @@ -1,6 +1,6 @@ services: theme.negotiator.switch_page_theme: class: Drupal\switch_page_theme\Theme\PageThemeNegotiator - arguments: ['@config.factory', '@path.current','@path.alias_manager', '@path.matcher', '@current_user', '@module_handler', '@request_stack', '@?domain.negotiator', '@?language_manager'] + arguments: ['@config.factory', '@path.current', '@path_alias.manager', '@path.matcher', '@current_user', '@module_handler', '@request_stack', '@?domain.negotiator', '@?language_manager'] tags: - { name: theme_negotiator, priority: 1 }