Skip to content
Snippets Groups Projects
Commit af8bc72a authored by Ted Cooper's avatar Ted Cooper
Browse files

[#3297262]: Update method of getting list of installed themes.

Compatible back to 8.7.0.
parent e765fd79
No related branches found
No related tags found
No related merge requests found
# Admin UI - Theme switcher
form_mode_manager.theme_switcher_settings:
title: 'Form Mode theme switcher'
description: 'xxx'
description: 'Allows configuration of the theme used by the entity form modes.'
weight: -10
parent: form_mode_manager.admin_settings
route_name: form_mode_manager.theme_switcher_settings
......@@ -6,6 +6,7 @@ use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ThemeExtensionList;
use Drupal\Core\Form\FormStateInterface;
use Drupal\form_mode_manager\Form\FormModeManagerFormBase;
use Drupal\form_mode_manager\FormModeManagerInterface;
......@@ -16,6 +17,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class FormModeThemeSwitcherForm extends FormModeManagerFormBase {
/**
* Provides a list of available themes.
*
* @var \Drupal\Core\Extension\ThemeExtensionList
*
* @see https://www.drupal.org/project/drupal/issues/2940481
*/
protected $themeList;
/**
* Constructs a CropWidgetForm object.
*
......@@ -29,10 +39,26 @@ class FormModeThemeSwitcherForm extends FormModeManagerFormBase {
* The cache tags invalidator.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
* @param \Drupal\Core\Extension\ThemeExtensionList $theme_extension_list
* The theme extension list service.
*/
public function __construct(ConfigFactoryInterface $config_factory, EntityDisplayRepositoryInterface $entity_display_repository, FormModeManagerInterface $form_mode_manager, CacheTagsInvalidatorInterface $cache_tags_invalidator, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($config_factory, $entity_display_repository, $form_mode_manager, $cache_tags_invalidator, $entity_type_manager);
public function __construct(
ConfigFactoryInterface $config_factory,
EntityDisplayRepositoryInterface $entity_display_repository,
FormModeManagerInterface $form_mode_manager,
CacheTagsInvalidatorInterface $cache_tags_invalidator,
EntityTypeManagerInterface $entity_type_manager,
ThemeExtensionList $theme_extension_list
) {
parent::__construct(
$config_factory,
$entity_display_repository,
$form_mode_manager,
$cache_tags_invalidator,
$entity_type_manager
);
$this->themeList = $theme_extension_list;
$this->ignoreExcluded = FALSE;
$this->ignoreActiveDisplay = FALSE;
}
......@@ -46,7 +72,8 @@ class FormModeThemeSwitcherForm extends FormModeManagerFormBase {
$container->get('entity_display.repository'),
$container->get('form_mode.manager'),
$container->get('cache_tags.invalidator'),
$container->get('entity_type.manager')
$container->get('entity_type.manager'),
$container->get('extension.list.theme')
);
}
......@@ -81,9 +108,11 @@ class FormModeThemeSwitcherForm extends FormModeManagerFormBase {
* {@inheritdoc}
*/
public function getActiveThemeOptions() {
$installed_themes = $this->themeList->getAllInstalledInfo();
$options = [];
foreach ($this->configFactory->get('system.theme.data') as $theme_name => $theme_extension) {
$options[$theme_name] = $theme_extension->info['name'];
foreach ($installed_themes as $theme_name => $theme_extension) {
$options[$theme_name] = $theme_extension['name'];
}
return $options;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment