diff --git a/core/config/install/core.extension.yml b/core/config/install/core.extension.yml index 1514a9e31df55eb534c92e216c08c763f7a656cf..ce74baed1829fe104bc1dc9df9543f24be8100d5 100644 --- a/core/config/install/core.extension.yml +++ b/core/config/install/core.extension.yml @@ -1,4 +1,2 @@ module: {} theme: {} -disabled: - theme: {} diff --git a/core/config/schema/core.extension.schema.yml b/core/config/schema/core.extension.schema.yml index 3b93d9297cebbd609acddbb747b46a99b0cae27d..1d09eeb58c07f38affeea55e895492cc1fbf87c5 100644 --- a/core/config/schema/core.extension.schema.yml +++ b/core/config/schema/core.extension.schema.yml @@ -10,17 +10,7 @@ core.extension: label: 'Weight' theme: type: sequence - label: 'Enabled themes' + label: 'Installed themes' sequence: - type: integer label: 'Weight' - disabled: - type: mapping - label: 'Disabled extensions' - mapping: - theme: - type: sequence - label: 'Disabled themes' - sequence: - - type: integer - label: 'Weight' diff --git a/core/core.services.yml b/core/core.services.yml index d72d30c441dc37efac1dda28e04fd91441549d32..0f4d5863753f96f22878ae62300c850bdd228405 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -283,7 +283,7 @@ services: arguments: ['%container.modules%', '@cache.bootstrap'] theme_handler: class: Drupal\Core\Extension\ThemeHandler - arguments: ['@config.factory', '@module_handler', '@state', '@info_parser', '@logger.channel.default', '@asset.css.collection_optimizer', '@config.installer', '@router.builder'] + arguments: ['@config.factory', '@module_handler', '@state', '@info_parser', '@logger.channel.default', '@asset.css.collection_optimizer', '@config.installer', '@config.manager', '@router.builder'] entity.manager: class: Drupal\Core\Entity\EntityManager arguments: ['@container.namespaces', '@module_handler', '@cache.discovery', '@language_manager', '@string_translation', '@class_resolver', '@typed_data_manager', '@entity.definitions.installed'] diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index b538cb425b09f15df8cf2bc7272bd939e5b7354d..aaab2254583da2704b05b99a3beb9cc25fe855b7 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1512,7 +1512,7 @@ function install_profile_modules(&$install_state) { * Installs themes. * * This does not use a batch, since installing themes is faster than modules and - * because an installation profile typically enables 1-3 themes only (default + * because an installation profile typically installs 1-3 themes only (default * theme, base theme, admin theme). * * @param $install_state @@ -1521,15 +1521,15 @@ function install_profile_modules(&$install_state) { function install_profile_themes(&$install_state) { $theme_handler = \Drupal::service('theme_handler'); - // ThemeHandler::enable() resets the current list of themes. The theme used in - // the installer is not necessarily in the list of themes to install, so + // ThemeHandler::install() resets the current list of themes. The theme used + // in the installer is not necessarily in the list of themes to install, so // retain the current list. // @see _drupal_maintenance_theme() $current_themes = $theme_handler->listInfo(); // Install the themes specified by the installation profile. $themes = $install_state['profile_info']['themes']; - $theme_handler->enable($themes); + $theme_handler->install($themes); foreach ($current_themes as $theme) { $theme_handler->addTheme($theme); diff --git a/core/includes/module.inc b/core/includes/module.inc index 023c10228bed7a1ca24b8b3aada18653067fdf76..2b668cbe5f663af2b8472f737e1dff5a73ae7e24 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -9,11 +9,11 @@ use Drupal\Core\Extension\ExtensionDiscovery; /** - * Builds a list of enabled themes. + * Builds a list of installed themes. * * @param $type * The type of list to return: - * - theme: All enabled themes. + * - theme: All installed themes. * * @return * An associative array of themes, keyed by name. diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 1268e122a5a09b97c6130234e93a24206b3f1257..3f6d623536b394aa6752701e227f582554762aca 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -77,7 +77,7 @@ * Either the name of a theme or a full theme object. * * @return bool - * Boolean TRUE if the theme is enabled or is the site administration theme; + * Boolean TRUE if the theme is installed or is the site administration theme; * FALSE otherwise. * * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. @@ -765,42 +765,6 @@ function theme_settings_convert_to_config(array $theme_settings, Config $config) return $config; } -/** - * Enables a given list of themes. - * - * @param $theme_list - * An array of theme names. - * - * @return bool - * Whether any of the given themes have been enabled. - * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * Use \Drupal::service('theme_handler')->enable(). - * - * @see \Drupal\Core\Extension\ThemeHandler::enable(). - */ -function theme_enable($theme_list) { - return \Drupal::service('theme_handler')->enable($theme_list); -} - -/** - * Disables a given list of themes. - * - * @param $theme_list - * An array of theme names. - * - * @return bool - * Whether any of the given themes have been disabled. - * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * Use \Drupal::service('theme_handler')->disable(). - * - * @see \Drupal\Core\Extension\ThemeHandler::disable(). - */ -function theme_disable($theme_list) { - return \Drupal::service('theme_handler')->disable($theme_list); -} - /** * @addtogroup themeable * @{ diff --git a/core/includes/update.inc b/core/includes/update.inc index a81d20f05d1e23fa867c58dcf0b79544a50dc8b7..9a4606e37d401a2627cda471dbbf86ded666d65f 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -23,9 +23,6 @@ function update_fix_compatibility() { foreach ($extension_config->get($type) as $name => $weight) { if (update_check_incompatibility($name, $type)) { $extension_config->clear("$type.$name"); - if ($type === 'theme') { - $extension_config->set("disabled.theme.$name", 0); - } $save = TRUE; } } diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index b87c76dde8f8dbf3ba20b8c36fddeb65865628d0..9992fa04edf0cb4a5eb2b0622f1ebf498b27d7df 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -124,7 +124,7 @@ class ConfigImporter { protected $themeHandler; /** - * Flag set to import system.theme during processing theme enable and disables. + * Flag set to import system.theme during processing theme install and uninstalls. * * @var bool */ @@ -252,8 +252,8 @@ protected function getEmptyExtensionsProcessedList() { 'uninstall' => array(), ), 'theme' => array( - 'enable' => array(), - 'disable' => array(), + 'install' => array(), + 'uninstall' => array(), ), ); } @@ -395,9 +395,9 @@ protected function createExtensionChangelist() { $module_list = array_reverse($module_list); $install = array_intersect(array_keys($module_list), $install); - // Work out what themes to enable and to disable. - $enable = array_diff(array_keys($new_extensions['theme']), array_keys($current_extensions['theme'])); - $disable = array_diff(array_keys($current_extensions['theme']), array_keys($new_extensions['theme'])); + // Work out what themes to install and to uninstall. + $theme_install = array_diff(array_keys($new_extensions['theme']), array_keys($current_extensions['theme'])); + $theme_uninstall = array_diff(array_keys($current_extensions['theme']), array_keys($new_extensions['theme'])); $this->extensionChangelist = array( 'module' => array( @@ -405,8 +405,8 @@ protected function createExtensionChangelist() { 'install' => $install, ), 'theme' => array( - 'enable' => $enable, - 'disable' => $disable, + 'install' => $theme_install, + 'uninstall' => $theme_uninstall, ), ); } @@ -441,20 +441,10 @@ protected function getExtensionChangelist($type, $op = NULL) { */ protected function getUnprocessedExtensions($type) { $changelist = $this->getExtensionChangelist($type); - - if ($type == 'theme') { - $unprocessed = array( - 'enable' => array_diff($changelist['enable'], $this->processedExtensions[$type]['enable']), - 'disable' => array_diff($changelist['disable'], $this->processedExtensions[$type]['disable']), - ); - } - else { - $unprocessed = array( - 'install' => array_diff($changelist['install'], $this->processedExtensions[$type]['install']), - 'uninstall' => array_diff($changelist['uninstall'], $this->processedExtensions[$type]['uninstall']), - ); - } - return $unprocessed; + return array( + 'install' => array_diff($changelist['install'], $this->processedExtensions[$type]['install']), + 'uninstall' => array_diff($changelist['uninstall'], $this->processedExtensions[$type]['uninstall']), + ); } /** @@ -533,7 +523,7 @@ public function initialize() { $this->totalExtensionsToProcess += count($modules[$op]); } $themes = $this->getUnprocessedExtensions('theme'); - foreach (array('enable', 'disable') as $op) { + foreach (array('install', 'uninstall') as $op) { $this->totalExtensionsToProcess += count($themes[$op]); } @@ -576,7 +566,7 @@ protected function processExtensions(array &$context) { $this->processExtension($operation['type'], $operation['op'], $operation['name']); $context['message'] = t('Synchronising extensions: @op @name.', array('@op' => $operation['op'], '@name' => $operation['name'])); $processed_count = count($this->processedExtensions['module']['install']) + count($this->processedExtensions['module']['uninstall']); - $processed_count += count($this->processedExtensions['theme']['disable']) + count($this->processedExtensions['theme']['enable']); + $processed_count += count($this->processedExtensions['theme']['uninstall']) + count($this->processedExtensions['theme']['install']); $context['finished'] = $processed_count / $this->totalExtensionsToProcess; } else { @@ -650,24 +640,16 @@ protected function finish(array &$context) { * on. If there is nothing left to do returns FALSE; */ protected function getNextExtensionOperation() { - foreach (array('install', 'uninstall') as $op) { - $modules = $this->getUnprocessedExtensions('module'); - if (!empty($modules[$op])) { - return array( - 'op' => $op, - 'type' => 'module', - 'name' => array_shift($modules[$op]), - ); - } - } - foreach (array('enable', 'disable') as $op) { - $themes = $this->getUnprocessedExtensions('theme'); - if (!empty($themes[$op])) { - return array( - 'op' => $op, - 'type' => 'theme', - 'name' => array_shift($themes[$op]), - ); + foreach (array('module', 'theme') as $type) { + foreach (array('install', 'uninstall') as $op) { + $unprocessed = $this->getUnprocessedExtensions($type); + if (!empty($unprocessed[$op])) { + return array( + 'op' => $op, + 'type' => $type, + 'name' => array_shift($unprocessed[$op]), + ); + } } } return FALSE; @@ -794,11 +776,11 @@ protected function processExtension($type, $op, $name) { $this->moduleHandler->loadAll(); } if ($type == 'theme') { - // Theme disables possible remove default or admin themes therefore we - // need to import this before doing any. If there are no disables and - // the default or admin theme is change this will be picked up whilst + // Theme uninstalls possible remove default or admin themes therefore we + // need to import this before doing any. If there are no uninstalls and + // the default or admin theme is changing this will be picked up whilst // processing configuration. - if ($op == 'disable' && $this->processedSystemTheme === FALSE) { + if ($op == 'uninstall' && $this->processedSystemTheme === FALSE) { $this->importConfig(StorageInterface::DEFAULT_COLLECTION, 'update', 'system.theme'); $this->configManager->getConfigFactory()->reset('system.theme'); $this->processedSystemTheme = TRUE; diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index a4a086ab3bce23450649b9e90f45b03d8ec03303..f42f1bd4b115f1eac233e71c3f55ad2a63e48e3d 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -12,12 +12,13 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigInstallerInterface; +use Drupal\Core\Config\ConfigManagerInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\Routing\RouteBuilder; use Psr\Log\LoggerInterface; /** - * Default theme handler using the config system for enabled/disabled themes. + * Default theme handler using the config system to store installation statuses. */ class ThemeHandler implements ThemeHandlerInterface { @@ -46,14 +47,14 @@ class ThemeHandler implements ThemeHandlerInterface { protected $list; /** - * The config factory to get the enabled themes. + * The config factory to get the installed themes. * * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; /** - * The module handler to fire themes_enabled/themes_disabled hooks. + * The module handler to fire themes_installed/themes_uninstalled hooks. * * @var \Drupal\Core\Extension\ModuleHandlerInterface */ @@ -88,7 +89,7 @@ class ThemeHandler implements ThemeHandlerInterface { protected $logger; /** - * The route builder to rebuild the routes if a theme is enabled. + * The route builder to rebuild the routes if a theme is installed. * * @var \Drupal\Core\Routing\RouteBuilder */ @@ -108,31 +109,41 @@ class ThemeHandler implements ThemeHandlerInterface { */ protected $cssCollectionOptimizer; + /** + * The config manager used to uninstall a theme. + * + * @var \Drupal\Core\Config\ConfigManagerInterface + */ + protected $configManager; + /** * Constructs a new ThemeHandler. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The config factory to get the enabled themes. + * The config factory to get the installed themes. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to fire themes_enabled/themes_disabled hooks. + * The module handler to fire themes_installed/themes_uninstalled hooks. * @param \Drupal\Core\State\StateInterface $state * The state store. * @param \Drupal\Core\Extension\InfoParserInterface $info_parser * The info parser to parse the theme.info.yml files. - * @param \Drupal\Core\Asset\AssetCollectionOptimizerInterface $css_collection_optimizer - * The CSS asset collection optimizer service. * @param \Psr\Log\LoggerInterface $logger * A logger instance. + * @param \Drupal\Core\Asset\AssetCollectionOptimizerInterface $css_collection_optimizer + * The CSS asset collection optimizer service. * @param \Drupal\Core\Config\ConfigInstallerInterface $config_installer * (optional) The config installer to install configuration. This optional * to allow the theme handler to work before Drupal is installed and has a * database. + * @param \Drupal\Core\Config\ConfigManagerInterface $config_manager + * The config manager used to uninstall a theme. * @param \Drupal\Core\Routing\RouteBuilder $route_builder - * (optional) The route builder to rebuild the routes if a theme is enabled. + * (optional) The route builder to rebuild the routes if a theme is + * installed. * @param \Drupal\Core\Extension\ExtensionDiscovery $extension_discovery * (optional) A extension discovery instance (for unit tests). */ - public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, StateInterface $state, InfoParserInterface $info_parser,LoggerInterface $logger, AssetCollectionOptimizerInterface $css_collection_optimizer = NULL, ConfigInstallerInterface $config_installer = NULL, RouteBuilder $route_builder = NULL, ExtensionDiscovery $extension_discovery = NULL) { + public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, StateInterface $state, InfoParserInterface $info_parser,LoggerInterface $logger, AssetCollectionOptimizerInterface $css_collection_optimizer = NULL, ConfigInstallerInterface $config_installer = NULL, ConfigManagerInterface $config_manager = NULL, RouteBuilder $route_builder = NULL, ExtensionDiscovery $extension_discovery = NULL) { $this->configFactory = $config_factory; $this->moduleHandler = $module_handler; $this->state = $state; @@ -140,6 +151,7 @@ public function __construct(ConfigFactoryInterface $config_factory, ModuleHandle $this->logger = $logger; $this->cssCollectionOptimizer = $css_collection_optimizer; $this->configInstaller = $config_installer; + $this->configManager = $config_manager; $this->routeBuilder = $route_builder; $this->extensionDiscovery = $extension_discovery; } @@ -157,7 +169,7 @@ public function getDefault() { public function setDefault($name) { $list = $this->listInfo(); if (!isset($list[$name])) { - throw new \InvalidArgumentException("$name theme is not enabled."); + throw new \InvalidArgumentException("$name theme is not installed."); } $this->configFactory->get('system.theme') ->set('default', $name) @@ -168,12 +180,12 @@ public function setDefault($name) { /** * {@inheritdoc} */ - public function enable(array $theme_list, $enable_dependencies = TRUE) { + public function install(array $theme_list, $install_dependencies = TRUE) { $extension_config = $this->configFactory->get('core.extension'); $theme_data = $this->rebuildThemeData(); - if ($enable_dependencies) { + if ($install_dependencies) { $theme_list = array_combine($theme_list, $theme_list); if ($missing = array_diff_key($theme_list, $theme_data)) { @@ -183,13 +195,12 @@ public function enable(array $theme_list, $enable_dependencies = TRUE) { ))); } - // Only process themes that are not enabled currently. + // Only process themes that are not installed currently. $installed_themes = $extension_config->get('theme') ?: array(); if (!$theme_list = array_diff_key($theme_list, $installed_themes)) { - // Nothing to do. All themes already enabled. + // Nothing to do. All themes already installed. return TRUE; } - $installed_themes += $extension_config->get('disabled.theme') ?: array(); while (list($theme) = each($theme_list)) { // Add dependencies to the list. The new themes will be processed as @@ -218,14 +229,13 @@ public function enable(array $theme_list, $enable_dependencies = TRUE) { } else { $installed_themes = $extension_config->get('theme') ?: array(); - $installed_themes += $extension_config->get('disabled.theme') ?: array(); } - $themes_enabled = array(); + $themes_installed = array(); foreach ($theme_list as $key) { - // Only process themes that are not already enabled. - $enabled = $extension_config->get("theme.$key") !== NULL; - if ($enabled) { + // Only process themes that are not already installed. + $installed = $extension_config->get("theme.$key") !== NULL; + if ($installed) { continue; } @@ -240,7 +250,6 @@ public function enable(array $theme_list, $enable_dependencies = TRUE) { // The value is not used; the weight is ignored for themes currently. $extension_config ->set("theme.$key", 0) - ->clear("disabled.theme.$key") ->save(); // Add the theme to the current list. @@ -263,11 +272,12 @@ public function enable(array $theme_list, $enable_dependencies = TRUE) { // Only install default configuration if this theme has not been installed // already. if (!isset($installed_themes[$key])) { - // The default config installation storage only knows about the currently - // enabled list of themes, so it has to be reset in order to pick up the - // default config of the newly installed theme. However, do not reset the - // source storage when synchronizing configuration, since that would - // needlessly trigger a reload of the whole configuration to be imported. + // The default config installation storage only knows about the + // currently installed list of themes, so it has to be reset in order to + // pick up the default config of the newly installed theme. However, do + // not reset the source storage when synchronizing configuration, since + // that would needlessly trigger a reload of the whole configuration to + // be imported. if (!$this->configInstaller->isSyncing()) { $this->configInstaller->resetSourceStorage(); } @@ -276,58 +286,57 @@ public function enable(array $theme_list, $enable_dependencies = TRUE) { $this->configInstaller->installDefaultConfig('theme', $key); } - $themes_enabled[] = $key; + $themes_installed[] = $key; - // Record the fact that it was enabled. - $this->logger->info('%theme theme enabled.', array('%theme' => $key)); + // Record the fact that it was installed. + $this->logger->info('%theme theme installed.', array('%theme' => $key)); } $this->cssCollectionOptimizer->deleteAll(); $this->resetSystem(); - // Invoke hook_themes_enabled() after the themes have been enabled. - $this->moduleHandler->invokeAll('themes_enabled', array($themes_enabled)); + // Invoke hook_themes_installed() after the themes have been installed. + $this->moduleHandler->invokeAll('themes_installed', array($themes_installed)); - return !empty($themes_enabled); + return !empty($themes_installed); } /** * {@inheritdoc} */ - public function disable(array $theme_list) { - $list = $this->listInfo(); + public function uninstall(array $theme_list) { + $extension_config = $this->configFactory->get('core.extension'); $theme_config = $this->configFactory->get('system.theme'); - + $list = $this->listInfo(); foreach ($theme_list as $key) { if (!isset($list[$key])) { throw new \InvalidArgumentException("Unknown theme: $key."); } if ($key === $theme_config->get('default')) { - throw new \InvalidArgumentException("The current default theme $key cannot be disabled."); + throw new \InvalidArgumentException("The current default theme $key cannot be uninstalled."); } if ($key === $theme_config->get('admin')) { - throw new \InvalidArgumentException("The current admin theme $key cannot be disabled."); + throw new \InvalidArgumentException("The current admin theme $key cannot be uninstalled."); } - // Base themes cannot be disabled if sub themes are enabled, and if they - // are not disabled at the same time. + // Base themes cannot be uninstalled if sub themes are installed, and if + // they are not uninstalled at the same time. + // @todo https://www.drupal.org/node/474684 and + // https://www.drupal.org/node/1297856 themes should leverage the module + // dependency system. if (!empty($list[$key]->sub_themes)) { foreach ($list[$key]->sub_themes as $sub_key => $sub_label) { if (isset($list[$sub_key]) && !in_array($sub_key, $theme_list, TRUE)) { - throw new \InvalidArgumentException("The base theme $key cannot be disabled, because theme $sub_key depends on it."); + throw new \InvalidArgumentException("The base theme $key cannot be uninstalled, because theme $sub_key depends on it."); } } } } $this->cssCollectionOptimizer->deleteAll(); - - $extension_config = $this->configFactory->get('core.extension'); $current_theme_data = $this->state->get('system.theme.data', array()); foreach ($theme_list as $key) { // The value is not used; the weight is ignored for themes currently. - $extension_config - ->clear("theme.$key") - ->set("disabled.theme.$key", 0); + $extension_config->clear("theme.$key"); // Remove the theme from the current list. unset($this->list[$key]); @@ -341,14 +350,17 @@ public function disable(array $theme_list) { // @todo Remove system_list(). $this->systemListReset(); + + // Remove all configuration belonging to the theme. + $this->configManager->uninstall('theme', $key); + } $extension_config->save(); $this->state->set('system.theme.data', $current_theme_data); $this->resetSystem(); - // Invoke hook_themes_disabled after the themes have been disabled. - $this->moduleHandler->invokeAll('themes_disabled', array($theme_list)); + $this->moduleHandler->invokeAll('themes_uninstalled', [$theme_list]); } /** @@ -400,13 +412,13 @@ public function addTheme(Extension $theme) { public function refreshInfo() { $this->reset(); $extension_config = $this->configFactory->get('core.extension'); - $enabled = $extension_config->get('theme'); + $installed = $extension_config->get('theme'); // @todo Avoid re-scanning all themes by retaining the original (unaltered) // theme info somewhere. $list = $this->rebuildThemeData(); foreach ($list as $name => $theme) { - if (isset($enabled[$name])) { + if (isset($installed[$name])) { $this->addTheme($theme); } } @@ -429,7 +441,7 @@ public function rebuildThemeData() { $themes = $listing->scan('theme'); $engines = $listing->scan('theme_engine'); $extension_config = $this->configFactory->get('core.extension'); - $enabled = $extension_config->get('theme') ?: array(); + $installed = $extension_config->get('theme') ?: array(); // Set defaults for theme info. $defaults = array( @@ -458,7 +470,7 @@ public function rebuildThemeData() { // Read info files for each theme. foreach ($themes as $key => $theme) { // @todo Remove all code that relies on the $status property. - $theme->status = (int) isset($enabled[$key]); + $theme->status = (int) isset($installed[$key]); $theme->info = $this->infoParser->parse($theme->getPathname()) + $defaults; diff --git a/core/lib/Drupal/Core/Extension/ThemeHandlerInterface.php b/core/lib/Drupal/Core/Extension/ThemeHandlerInterface.php index 74f9ad29035e7888f366f7f97258bc5aa3199bb1..aa198d64ac23dd35cc2aaddb822ae43b2496c00e 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandlerInterface.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandlerInterface.php @@ -8,49 +8,54 @@ namespace Drupal\Core\Extension; /** - * Manages the list of available themes as well as enable/disable them. + * Manages the list of available themes as well as install/uninstall them. */ interface ThemeHandlerInterface { /** - * Enables a given list of themes. + * Installs a given list of themes. * * @param array $theme_list * An array of theme names. - * @param bool $enable_dependencies + * @param bool $install_dependencies * (optional) If TRUE, dependencies will automatically be installed in the * correct order. This incurs a significant performance cost, so use FALSE * if you know $theme_list is already complete and in the correct order. * * @return bool - * Whether any of the given themes have been enabled. + * Whether any of the given themes have been installed. * * @throws \Drupal\Core\Extension\ExtensionNameLengthException * Thrown when the theme name is to long */ - public function enable(array $theme_list, $enable_dependencies = TRUE); + public function install(array $theme_list, $install_dependencies = TRUE); /** - * Disables a given list of themes. + * Uninstalls a given list of themes. + * + * Uninstalling a theme removes all related configuration (like blocks) and + * invokes the 'themes_uninstalled' hook. * * @param array $theme_list - * An array of theme names. + * The themes to uninstall. * - * @return bool - * Whether any of the given themes have been disabled. + * @throws \InvalidArgumentException + * Thrown when you uninstall an not installed theme. + * + * @see hook_themes_uninstalled() */ - public function disable(array $theme_list); + public function uninstall(array $theme_list); /** - * Returns a list of currently enabled themes. + * Returns a list of currently installed themes. * * @return \Drupal\Core\Extension\Extension[] - * An associative array of the currently enabled themes. The keys are the + * An associative array of the currently installed themes. The keys are the * themes' machine names and the values are objects having the following * properties: * - filename: The filepath and name of the .info.yml file. * - name: The machine name of the theme. - * - status: 1 for enabled, 0 for disabled themes. + * - status: 1 for installed, 0 for uninstalled themes. * - info: The contents of the .info.yml file. * - stylesheets: A two dimensional array, using the first key for the * media attribute (e.g. 'all'), the second for the name of the file @@ -83,7 +88,7 @@ public function disable(array $theme_list); public function listInfo(); /** - * Refreshes the theme info data of currently enabled themes. + * Refreshes the theme info data of currently installed themes. * * Modules can alter theme info, so this is typically called after a module * has been installed or uninstalled. @@ -140,7 +145,17 @@ public function getName($theme); public function getDefault(); /** - * Returns an array of directories for all enabled themes. + * Sets a new default theme. + * + * @param string $theme + * The new default theme. + * + * @return $this + */ + public function setDefault($theme); + + /** + * Returns an array of directories for all installed themes. * * Useful for tasks such as finding a file that exists in all theme * directories. @@ -150,13 +165,13 @@ public function getDefault(); public function getThemeDirectories(); /** - * Determines whether a given theme is enabled. + * Determines whether a given theme is installed. * * @param string $theme * The name of the theme (without the .theme extension). * * @return bool - * TRUE if the theme is both installed and enabled. + * TRUE if the theme is installed. */ public function themeExists($theme); diff --git a/core/lib/Drupal/Core/Theme/ThemeAccessCheck.php b/core/lib/Drupal/Core/Theme/ThemeAccessCheck.php index 6c2a4c1d303709c9de79136f6a739fd6f20a7ed8..2927756a200328c9529f28723b6e8dc0577d66c5 100644 --- a/core/lib/Drupal/Core/Theme/ThemeAccessCheck.php +++ b/core/lib/Drupal/Core/Theme/ThemeAccessCheck.php @@ -30,13 +30,13 @@ public function access($theme) { } /** - * Indicates whether the theme is accessible based on whether it is enabled. + * Indicates whether the theme is accessible based on whether it is installed. * * @param string $theme * The name of a theme. * * @return bool - * TRUE if the theme is enabled, FALSE otherwise. + * TRUE if the theme is installed, FALSE otherwise. */ public function checkAccess($theme) { $themes = list_themes(); diff --git a/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/core/lib/Drupal/Core/Theme/ThemeInitialization.php index c6d800e1757ef87819599d42520fe61132caeefb..d4e1d952a23862b2df92b3cdcbdeac9b3f80905c 100644 --- a/core/lib/Drupal/Core/Theme/ThemeInitialization.php +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php @@ -64,15 +64,15 @@ public function getActiveThemeByName($theme_name) { $themes = $this->themeHandler->listInfo(); // If no theme could be negotiated, or if the negotiated theme is not within - // the list of enabled themes, fall back to the default theme output of core - // and modules (like Stark, but without a theme extension at all). This is - // possible, because loadActiveTheme() always loads the Twig theme engine. - // This is desired, because missing or malformed theme configuration should - // not leave the application in a broken state. By falling back to default - // output, the user is able to reconfigure the theme through the UI. + // the list of installed themes, fall back to the default theme output of + // core and modules (like Stark, but without a theme extension at all). This + // is possible, because loadActiveTheme() always loads the Twig theme + // engine. This is desired, because missing or malformed theme configuration + // should not leave the application in a broken state. By falling back to + // default output, the user is able to reconfigure the theme through the UI. // Lastly, tests are expected to operate with no theme by default, so as to // only assert the original theme output of modules (unless a test manually - // enables a specific theme). + // installs a specific theme). if (empty($themes) || !$theme_name || !isset($themes[$theme_name])) { $theme_name = 'core'; // /core/core.info.yml does not actually exist, but is required because diff --git a/core/lib/Drupal/Core/Updater/Theme.php b/core/lib/Drupal/Core/Updater/Theme.php index 4bd716a009234e1475f9c8876f4bc9c62f88f7ad..7e17dddb1eab384459662bdfc39ea2fa60939556 100644 --- a/core/lib/Drupal/Core/Updater/Theme.php +++ b/core/lib/Drupal/Core/Updater/Theme.php @@ -82,7 +82,7 @@ public function postInstall() { */ public function postInstallTasks() { return array( - l(t('Enable newly added themes'), 'admin/appearance'), + l(t('Install newly added themes'), 'admin/appearance'), l(t('Administration pages'), 'admin'), ); } diff --git a/core/lib/Drupal/Core/Utility/ProjectInfo.php b/core/lib/Drupal/Core/Utility/ProjectInfo.php index 2a49c8c37551c5a2b85e95762fe6749ad714aff0..a2cf7a4b83bd363e255bc5046103f831c8f8bb8a 100644 --- a/core/lib/Drupal/Core/Utility/ProjectInfo.php +++ b/core/lib/Drupal/Core/Utility/ProjectInfo.php @@ -19,6 +19,10 @@ class ProjectInfo { /** * Populates an array of project data. * + * @todo https://www.drupal.org/node/2338167 update class since extensions can + * no longer be hidden, enabled or disabled. Additionally, base themes have + * to be installed for sub themes to work. + * * This iterates over a list of the installed modules or themes and groups * them by project and status. A few parts of this function assume that * enabled modules and themes are always processed first, and if disabled @@ -51,15 +55,15 @@ function processInfoList(array &$projects, array $list, $project_type, $status, // projects list. if ($status && !empty($file->sub_themes)) { foreach ($file->sub_themes as $key => $name) { - // Build a list of enabled sub-themes. + // Build a list of installed sub-themes. if ($list[$key]->status) { - $file->enabled_sub_themes[$key] = $name; + $file->installed_sub_themes[$key] = $name; } } - // If the theme is disabled and there are no enabled subthemes, we - // should ignore this base theme for the enabled case. If the site is - // trying to display disabled themes, we'll catch it then. - if (!$file->status && empty($file->enabled_sub_themes)) { + // If the theme is uninstalled and there are no installed subthemes, we + // should ignore this base theme for the installed case. If the site is + // trying to display uninstalled themes, we'll catch it then. + if (!$file->status && empty($file->installed_sub_themes)) { continue; } } @@ -73,8 +77,9 @@ function processInfoList(array &$projects, array $list, $project_type, $status, continue; } - // Skip if it's a hidden module or hidden theme without enabled sub-themes. - if (!empty($file->info['hidden']) && empty($file->enabled_sub_themes)) { + // Skip if it's a hidden module or hidden theme without installed + // sub-themes. + if (!empty($file->info['hidden']) && empty($file->installed_sub_themes)) { continue; } @@ -115,10 +120,10 @@ function processInfoList(array &$projects, array $list, $project_type, $status, else { $project_display_type = $project_type; } - if (empty($status) && empty($file->enabled_sub_themes)) { + if (empty($status) && empty($file->installed_sub_themes)) { // If we're processing disabled modules or themes, append a suffix. - // However, we don't do this to a a base theme with enabled - // subthemes, since we treat that case as if it is enabled. + // However, we don't do this to a base theme with installed + // subthemes, since we treat that case as if it is installed. $project_display_type .= '-disabled'; } // Add a list of sub-themes that "depend on" the project and a list of base @@ -129,8 +134,8 @@ function processInfoList(array &$projects, array $list, $project_type, $status, $base_themes = array(); } else { - // Add list of enabled sub-themes. - $sub_themes = !empty($file->enabled_sub_themes) ? $file->enabled_sub_themes : array(); + // Add list of installed sub-themes. + $sub_themes = !empty($file->installed_sub_themes) ? $file->installed_sub_themes : array(); // Add list of base themes. $base_themes = !empty($file->base_themes) ? $file->base_themes : array(); } diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 9d31839e3e0dda91ffd38633f04f7b984e0d14e2..bcf550123d27d2b07e5ddb22c1ab4d6a0c190034 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -27,7 +27,7 @@ function block_help($route_name, RouteMatchInterface $route_match) { $output .= '
' . t('Demonstrating block regions for a theme') . '
'; $output .= '
' . t('You can see which region is where in a theme by clicking an the Demonstrate block regions link on the Block layout page. Regions are specific to each theme, so you need to toggle to a different theme first to demonstrate its block regions.', array('!blocks' => \Drupal::url('block.admin_display'))) . '
'; $output .= '
' . t('Toggling between different themes') . '
'; - $output .= '
' . t('Blocks are placed and configured specifically for each theme. The Block layout page opens with the default theme, but you can toggle to other enabled themes.') . '
'; + $output .= '
' . t('Blocks are placed and configured specifically for each theme. The Block layout page opens with the default theme, but you can toggle to other installed themes.') . '
'; $output .= '
' . t('Configuring block settings') . '
'; $output .= '
' . t('To change the settings of an individual block click on the Configure link on the Block layout page. The available options vary depending on the module that provides the block. For all blocks you can change the block title and toggle whether to display it.', array('!blocks' => Drupal::url('block.admin_display'))) . '
'; $output .= '
' . t('Controlling visibility') . '
'; @@ -139,12 +139,12 @@ function _block_rehash($theme = NULL) { } /** - * Initializes blocks for enabled themes. + * Initializes blocks for installed themes. * * @param $theme_list * An array of theme names. */ -function block_themes_enabled($theme_list) { +function block_themes_installed($theme_list) { foreach ($theme_list as $theme) { block_theme_initialize($theme); } @@ -153,9 +153,9 @@ function block_themes_enabled($theme_list) { /** * Assigns an initial, default set of blocks for a theme. * - * This function is called the first time a new theme is enabled. The new theme - * gets a copy of the default theme's blocks, with the difference that if a - * particular region isn't available in the new theme, the block is assigned + * This function is called the first time a new theme is installed. The new + * theme gets a copy of the default theme's blocks, with the difference that if + * a particular region isn't available in the new theme, the block is assigned * to the new theme's default region. * * @param $theme diff --git a/core/modules/block/src/Tests/BlockAdminThemeTest.php b/core/modules/block/src/Tests/BlockAdminThemeTest.php index 20b892cc749af73562212d9a42d5e1357fa2514c..9a86f29271f760cc404d91d83e344bffd8e88653 100644 --- a/core/modules/block/src/Tests/BlockAdminThemeTest.php +++ b/core/modules/block/src/Tests/BlockAdminThemeTest.php @@ -31,12 +31,13 @@ function testAdminTheme() { $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes')); $this->drupalLogin($admin_user); - // Ensure that access to block admin page is denied when theme is disabled. + // Ensure that access to block admin page is denied when theme is not + // installed. $this->drupalGet('admin/structure/block/list/bartik'); $this->assertResponse(403); - // Enable admin theme and confirm that tab is accessible. - theme_enable(array('bartik')); + // Install admin theme and confirm that tab is accessible. + \Drupal::service('theme_handler')->install(array('bartik')); $edit['admin_theme'] = 'bartik'; $this->drupalPostForm('admin/appearance', $edit, t('Save configuration')); $this->drupalGet('admin/structure/block/list/bartik'); diff --git a/core/modules/block/src/Tests/BlockHiddenRegionTest.php b/core/modules/block/src/Tests/BlockHiddenRegionTest.php index c46d082f40ae4f8598b40a33d47dd02364744e4f..95b06f3beb0d47a36577b515aefee06e02ad938e 100644 --- a/core/modules/block/src/Tests/BlockHiddenRegionTest.php +++ b/core/modules/block/src/Tests/BlockHiddenRegionTest.php @@ -10,7 +10,7 @@ use Drupal\simpletest\WebTestBase; /** - * Tests that a newly enabled theme does not inherit blocks to its hidden + * Tests that a newly installed theme does not inherit blocks to its hidden * regions. * * @group block @@ -45,7 +45,7 @@ protected function setUp() { } /** - * Tests that hidden regions do not inherit blocks when a theme is enabled. + * Tests that hidden regions do not inherit blocks when a theme is installed. */ public function testBlockNotInHiddenRegion() { @@ -53,13 +53,13 @@ public function testBlockNotInHiddenRegion() { $this->drupalGet(''); $this->assertText('Search', 'Block was displayed on the front page.'); - // Enable "block_test_theme" and set it as the default theme. + // Install "block_test_theme" and set it as the default theme. $theme = 'block_test_theme'; - theme_enable(array($theme)); + \Drupal::service('theme_handler')->install(array($theme)); \Drupal::config('system.theme') ->set('default', $theme) ->save(); - // Enabling a theme will cause the kernel terminate event to rebuild the + // Installing a theme will cause the kernel terminate event to rebuild the // router. Simulate that here. \Drupal::service('router.builder')->rebuildIfNeeded(); diff --git a/core/modules/block/src/Tests/BlockTest.php b/core/modules/block/src/Tests/BlockTest.php index 6240fcd508cea900c288f7e290a0e70837bb037a..234077ccc02c21b49f373804ec00e0d0ec067953 100644 --- a/core/modules/block/src/Tests/BlockTest.php +++ b/core/modules/block/src/Tests/BlockTest.php @@ -154,8 +154,8 @@ function testBlock() { * Tests that the block form has a theme selector when not passed via the URL. */ public function testBlockThemeSelector() { - // Enable all themes. - theme_enable(array('bartik', 'seven')); + // Install all themes. + \Drupal::service('theme_handler')->install(array('bartik', 'seven')); $theme_settings = $this->container->get('config.factory')->get('system.theme'); foreach (array('bartik', 'stark', 'seven') as $theme) { $this->drupalGet('admin/structure/block/list/' . $theme); @@ -185,7 +185,7 @@ function testThemeName() { $this->drupalPlaceBlock('system_help_block', array('region' => 'help')); // Explicitly set the default and admin themes. $theme = 'block_test_specialchars_theme'; - theme_enable(array($theme)); + \Drupal::service('theme_handler')->install(array($theme)); \Drupal::service('router.builder')->rebuild(); $this->drupalGet('admin/structure/block'); $this->assertRaw(String::checkPlain('<"Cat" & \'Mouse\'>')); @@ -377,4 +377,24 @@ public function testBlockCacheTags() { $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS'); } + /** + * Tests that uninstalling a theme removes its block configuration. + */ + public function testUninstallTheme() { + /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */ + $theme_handler = \Drupal::service('theme_handler'); + + $theme_handler->install(['seven']); + $theme_handler->setDefault('seven'); + $block = $this->drupalPlaceBlock('system_powered_by_block', ['theme' => 'seven', 'region' => 'help']); + $this->drupalGet(''); + $this->assertText('Powered by Drupal'); + + $theme_handler->setDefault('stark'); + $theme_handler->uninstall(['seven']); + + // Ensure that the block configuration does not exist anymore. + $this->assertIdentical(NULL, Block::load($block->id())); + } + } diff --git a/core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php b/core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php index 9a6642c545c5daf54aac3e577241d96ab929ec5c..847197677396682289971768ea780c1616cf856a 100644 --- a/core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php +++ b/core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php @@ -42,10 +42,10 @@ function testNewDefaultThemeBlocks() { 'id' => $default_theme . '_' . strtolower($this->randomMachineName(8)), )); - // Enable a different theme. + // Install a different theme. $new_theme = 'bartik'; $this->assertFalse($new_theme == $default_theme, 'The new theme is different from the previous default theme.'); - theme_enable(array($new_theme)); + \Drupal::service('theme_handler')->install(array($new_theme)); \Drupal::config('system.theme') ->set('default', $new_theme) ->save(); diff --git a/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php b/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php index f7ffd37b59ec6fadaf3c51bb9e3617962786b05b..c2e7e031dd9a66eab90deddd40ef3932827af10a 100644 --- a/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php +++ b/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php @@ -30,7 +30,7 @@ function testNonDefaultBlockAdmin() { $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes')); $this->drupalLogin($admin_user); $new_theme = 'bartik'; - theme_enable(array($new_theme)); + \Drupal::service('theme_handler')->install(array($new_theme)); $this->drupalGet('admin/structure/block/list/' . $new_theme); $this->assertText('Bartik(' . t('active tab') . ')', 'Tab for non-default theme found.'); } diff --git a/core/modules/block_content/src/Tests/BlockContentTypeTest.php b/core/modules/block_content/src/Tests/BlockContentTypeTest.php index b36d009f9018af797980efb8c12dd3b56fbb0f27..8a20eec7b0a24bce5a43bb4fb7f529a3e8b0f54c 100644 --- a/core/modules/block_content/src/Tests/BlockContentTypeTest.php +++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php @@ -142,8 +142,8 @@ public function testsBlockContentAddTypes() { ->get('entity.manager') ->getStorage('block_content'); - // Enable all themes. - theme_enable(array('bartik', 'seven')); + // Install all themes. + \Drupal::service('theme_handler')->install(array('bartik', 'seven')); $themes = array('bartik', 'seven', 'stark'); $theme_settings = $this->container->get('config.factory')->get('system.theme'); foreach ($themes as $default_theme) { @@ -151,7 +151,7 @@ public function testsBlockContentAddTypes() { $theme_settings->set('default', $default_theme)->save(); \Drupal::service('router.builder')->rebuild(); - // For each enabled theme, go to its block page and test the redirects. + // For each installed theme, go to its block page and test the redirects. $themes = array('bartik', 'stark', 'seven'); foreach ($themes as $theme) { // Test that adding a block from the 'place blocks' form sends you to the diff --git a/core/modules/breakpoint/breakpoint.module b/core/modules/breakpoint/breakpoint.module index 35187b1614fd7efb5ac262323f64623c57d3f87e..eff0aef4d2e9e538085a4435618dca257a0d3b5f 100644 --- a/core/modules/breakpoint/breakpoint.module +++ b/core/modules/breakpoint/breakpoint.module @@ -37,15 +37,15 @@ function breakpoint_help($route_name, RouteMatchInterface $route_match) { } /** - * Implements hook_themes_enabled() + * Implements hook_themes_installed() */ -function breakpoint_themes_enabled($theme_list) { +function breakpoint_themes_installed($theme_list) { \Drupal::service('breakpoint.manager')->clearCachedDefinitions(); } /** - * Implements hook_themes_disabled() + * Implements hook_themes_uninstalled() */ -function breakpoint_themes_disabled($theme_list) { +function breakpoint_themes_uninstalled($theme_list) { \Drupal::service('breakpoint.manager')->clearCachedDefinitions(); } diff --git a/core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php b/core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php index c7dda9465529fb0fffa6e25427b15f3b58eaaf88..a8a46f95d86f88f2231eeca5f4a9eef66e4545e5 100644 --- a/core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php +++ b/core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php @@ -24,7 +24,7 @@ class BreakpointDiscoveryTest extends KernelTestBase { protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->enable(array('breakpoint_theme_test')); + \Drupal::service('theme_handler')->install(array('breakpoint_theme_test')); } /** diff --git a/core/modules/color/src/Tests/ColorConfigSchemaTest.php b/core/modules/color/src/Tests/ColorConfigSchemaTest.php index 3b49e17d3be4cafab490b33065681c0caa41b965..a5c9d333b14a8372da24f12dbd4d8d8f1cb215ab 100644 --- a/core/modules/color/src/Tests/ColorConfigSchemaTest.php +++ b/core/modules/color/src/Tests/ColorConfigSchemaTest.php @@ -38,7 +38,7 @@ class ColorConfigSchemaTest extends WebTestBase { */ protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->enable(array('bartik')); + \Drupal::service('theme_handler')->install(array('bartik')); // Create user. $this->adminUser = $this->drupalCreateUser(array('administer themes')); diff --git a/core/modules/color/src/Tests/ColorTest.php b/core/modules/color/src/Tests/ColorTest.php index c7260a1c6a1d43bd8bf93355769d2ee270966f9f..fb400a352f06c82170c649af74beba08cd75a2c9 100644 --- a/core/modules/color/src/Tests/ColorTest.php +++ b/core/modules/color/src/Tests/ColorTest.php @@ -70,7 +70,7 @@ protected function setUp() { 'scheme_color' => '#3b3b3b', ), ); - theme_enable(array_keys($this->themes)); + \Drupal::service('theme_handler')->install(array_keys($this->themes)); // Array filled with valid and not valid color values. $this->colorTests = array( diff --git a/core/modules/comment/src/Tests/CommentLinksTest.php b/core/modules/comment/src/Tests/CommentLinksTest.php index 00484b60b22f724d55f5445e2803820f884a52c4..34b8b41aeda5f26dae748f368d3b22a21edf711d 100644 --- a/core/modules/comment/src/Tests/CommentLinksTest.php +++ b/core/modules/comment/src/Tests/CommentLinksTest.php @@ -47,7 +47,7 @@ class CommentLinksTest extends CommentTestBase { */ public function testCommentLinks() { // Bartik theme alters comment links, so use a different theme. - \Drupal::service('theme_handler')->enable(array('stark')); + \Drupal::service('theme_handler')->install(array('stark')); \Drupal::config('system.theme') ->set('default', 'stark') ->save(); diff --git a/core/modules/config/src/Tests/ConfigImportUITest.php b/core/modules/config/src/Tests/ConfigImportUITest.php index f5e49477a8a3f9f410ad10881e7aa84e32148ad7..959b2f189951b5f12732b75bdb0f6ff51c9ea4b0 100644 --- a/core/modules/config/src/Tests/ConfigImportUITest.php +++ b/core/modules/config/src/Tests/ConfigImportUITest.php @@ -141,7 +141,7 @@ function testImport() { $this->assertTrue(\Drupal::moduleHandler()->moduleExists('text'), 'Text module installed during import.'); $theme_info = \Drupal::service('theme_handler')->listInfo(); - $this->assertTrue($theme_info['bartik']->status, 'Bartik theme enabled during import.'); + $this->assertTrue($theme_info['bartik']->status, 'Bartik theme installed during import.'); // Ensure installations and uninstallation occur as expected. $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', array()); @@ -164,7 +164,6 @@ function testImport() { unset($core_extension['module']['options']); unset($core_extension['module']['text']); unset($core_extension['theme']['bartik']); - $core_extension['disabled']['theme']['bartik'] = 0; $staging->write('core.extension', $core_extension); $staging->delete('action.settings'); $staging->delete('text.settings'); @@ -205,7 +204,7 @@ function testImport() { $this->assertTrue(empty($installed), 'No modules installed during import'); $theme_info = \Drupal::service('theme_handler')->listInfo(); - $this->assertFalse(isset($theme_info['bartik']), 'Bartik theme disabled during import.'); + $this->assertFalse(isset($theme_info['bartik']), 'Bartik theme uninstalled during import.'); // Verify that the action.settings configuration object was only deleted // once during the import process. diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index 6958c80cff6a6682f389b844d0716a7e26689975..e21c1000a8f93d56a89e91dd4f2fc2e9339e88d0 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -49,9 +49,9 @@ function config_translation_theme() { } /** - * Implements hook_themes_enabled(). + * Implements hook_themes_installed(). */ -function config_translation_themes_enabled() { +function config_translation_themes_installed() { // Themes can provide *.config_translation.yml declarations. // @todo Make ThemeHandler trigger an event instead and make // ConfigMapperManager plugin manager subscribe to it. @@ -60,9 +60,9 @@ function config_translation_themes_enabled() { } /** - * Implements hook_themes_disabled(). + * Implements hook_themes_uninstalled(). */ -function config_translation_themes_disabled() { +function config_translation_themes_uninstalled() { // Themes can provide *.config_translation.yml declarations. // @todo Make ThemeHandler trigger an event instead and make // ConfigMapperManager plugin manager subscribe to it. diff --git a/core/modules/config_translation/src/ConfigMapperManager.php b/core/modules/config_translation/src/ConfigMapperManager.php index 6c99ce154bab428521dcf63da7dbeac7543bdcd6..2335ffe5bb86f7310e174a73bdfc7dc3116819ae 100644 --- a/core/modules/config_translation/src/ConfigMapperManager.php +++ b/core/modules/config_translation/src/ConfigMapperManager.php @@ -68,14 +68,14 @@ public function __construct(CacheBackendInterface $cache_backend, LanguageManage $this->typedConfigManager = $typed_config_manager; // Look at all themes and modules. - // @todo If the list of enabled modules and themes is changed, new + // @todo If the list of installed modules and themes is changed, new // definitions are not picked up immediately and obsolete definitions are // not removed, because the list of search directories is only compiled // once in this constructor. The current code only works due to - // coincidence: The request that enables e.g. a new theme does not + // coincidence: The request that installs e.g. a new theme does not // instantiate this plugin manager at the beginning of the request; when // routes are being rebuilt at the end of the request, this service only - // happens to get instantiated with the updated list of enabled themes. + // happens to get instantiated with the updated list of installed themes. $directories = array(); foreach ($module_handler->getModuleList() as $name => $module) { $directories[$name] = $module->getPath(); diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php index bb393798d71d13f162dcce726c43f73a62678ee4..7aa82057c9081dff66c439b706fa51ac8df4ae2f 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php @@ -60,14 +60,14 @@ protected function setUp() { * Tests that theme provided *.config_translation.yml files are found. */ public function testThemeDiscovery() { - // Enable the test theme and rebuild routes. + // Install the test theme and rebuild routes. $theme = 'config_translation_test_theme'; $this->drupalLogin($this->admin_user); $this->drupalGet('admin/appearance'); $elements = $this->xpath('//a[normalize-space()=:label and contains(@href, :theme)]', array( - ':label' => 'Enable and set as default', + ':label' => 'Install and set as default', ':theme' => $theme, )); $this->drupalGet($GLOBALS['base_root'] . $elements[0]['href'], array('external' => TRUE)); diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 11ffc27616072e02bc00c8fda6b2dc0a64a2a747..5740e4a8993fcff17189e7c45063ddd0fc5a386b 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -343,20 +343,17 @@ function locale_modules_uninstalled($modules) { } /** - * Implements hook_themes_enabled(). - * - * @todo This is technically wrong. We must not import upon enabling, but upon - * initial installation. The theme system is missing an installation hook. + * Implements hook_themes_installed(). */ -function locale_themes_enabled($themes) { +function locale_themes_installed($themes) { $components['theme'] = $themes; locale_system_update($components); } /** - * Implements hook_themes_disabled(). + * Implements hook_themes_uninstalled(). */ -function locale_themes_disabled($themes) { +function locale_themes_uninstalled($themes) { $components['theme'] = $themes; locale_system_remove($components); } diff --git a/core/modules/menu_link_content/src/Tests/MenuLinkContentUITest.php b/core/modules/menu_link_content/src/Tests/MenuLinkContentUITest.php index 3a3e027f96bc4feadc3caf6b98c0cb4f6595e440..a876fb3ffb492b6786c6f8ecc50d272ac65b2a3f 100644 --- a/core/modules/menu_link_content/src/Tests/MenuLinkContentUITest.php +++ b/core/modules/menu_link_content/src/Tests/MenuLinkContentUITest.php @@ -70,7 +70,7 @@ function testTranslationLinkTheme() { $entityId = $this->createEntity(array(), 'en'); // Set up Seven as the admin theme to test. - $this->container->get('theme_handler')->enable(array('seven')); + $this->container->get('theme_handler')->install(array('seven')); $edit = array(); $edit['admin_theme'] = 'seven'; $this->drupalPostForm('admin/appearance', $edit, t('Save configuration')); diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php index d8bf38c6fc30004c071178978772869b8c82499f..4b15b05e6aa9b8a0dd5a94cf74de43d30cc49514 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php @@ -65,8 +65,8 @@ protected function setUp() { $config->set('admin', 'seven'); $config->save(); - // Enable one of D8's test themes. - \Drupal::service('theme_handler')->enable(array('test_theme')); + // Install one of D8's test themes. + \Drupal::service('theme_handler')->install(array('test_theme')); /** @var \Drupal\migrate\entity\Migration $migration */ $migration = entity_load('migration', 'd6_block'); diff --git a/core/modules/node/src/Tests/NodeTranslationUITest.php b/core/modules/node/src/Tests/NodeTranslationUITest.php index 9c0ffacb0448571b2a64502bafd372a5711be23e..13eced4a4ab82df5a0b3a4abdc06aaaaba2e777e 100644 --- a/core/modules/node/src/Tests/NodeTranslationUITest.php +++ b/core/modules/node/src/Tests/NodeTranslationUITest.php @@ -182,7 +182,7 @@ function testTranslationLinkTheme() { $article = $this->drupalCreateNode(array('type' => 'article', 'langcode' => $this->langcodes[0])); // Set up Seven as the admin theme and use it for node editing. - $this->container->get('theme_handler')->enable(array('seven')); + $this->container->get('theme_handler')->install(array('seven')); $edit = array(); $edit['admin_theme'] = 'seven'; $edit['use_admin_theme'] = TRUE; diff --git a/core/modules/responsive_image/src/ResponsiveImageMappingForm.php b/core/modules/responsive_image/src/ResponsiveImageMappingForm.php index 6e35126908b0540271437400732bb8e9a4e6941b..0ad61cae00e3cf5efef101852f9dbd0ee5b0868d 100644 --- a/core/modules/responsive_image/src/ResponsiveImageMappingForm.php +++ b/core/modules/responsive_image/src/ResponsiveImageMappingForm.php @@ -84,10 +84,10 @@ public function form(array $form, FormStateInterface $form_state) { ); if ((bool) $responsive_image_mapping->id() && $this->operation != 'duplicate') { - $description = $this->t('Select a breakpoint group from the enabled themes.') . ' ' . $this->t("Warning: if you change the breakpoint group you lose all your selected mappings."); + $description = $this->t('Select a breakpoint group from the installed themes.') . ' ' . $this->t("Warning: if you change the breakpoint group you lose all your selected mappings."); } else { - $description = $this->t('Select a breakpoint group from the enabled themes.'); + $description = $this->t('Select a breakpoint group from the installed themes.'); } $form['breakpointGroup'] = array( '#type' => 'select', diff --git a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php index 2b4c73172ce1388cad1aed11fdb800bcbd6e1db5..24c5550902d5bb7c20ac1071ee513cafb9c36f3c 100644 --- a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php +++ b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php @@ -99,7 +99,7 @@ public function testShortcutLinkAdd() { * Tests that the "add to shortcut" and "remove from shortcut" links work. */ public function testShortcutQuickLink() { - theme_enable(array('seven')); + \Drupal::service('theme_handler')->install(array('seven')); \Drupal::config('system.theme')->set('admin', 'seven')->save(); $this->container->get('config.factory')->get('node.settings')->set('use_admin_theme', '1')->save(); $this->container->get('router.builder')->rebuild(); @@ -202,7 +202,7 @@ public function testShortcutLinkDelete() { */ public function testNoShortcutLink() { // Change to a theme that displays shortcuts. - theme_enable(array('seven')); + \Drupal::service('theme_handler')->install(array('seven')); \Drupal::config('system.theme') ->set('default', 'seven') ->save(); @@ -233,7 +233,7 @@ public function testNoShortcutLink() { */ public function testAccessShortcutsPermission() { // Change to a theme that displays shortcuts. - \Drupal::service('theme_handler')->enable(array('seven')); + \Drupal::service('theme_handler')->install(array('seven')); \Drupal::config('system.theme') ->set('default', 'seven') ->save(); diff --git a/core/modules/system/css/system.admin.css b/core/modules/system/css/system.admin.css index 0031327c7ab146f018bcd457068e424d8eba7d98..853ded2f014b37a0f2a4f133c6bc19b7249de752 100644 --- a/core/modules/system/css/system.admin.css +++ b/core/modules/system/css/system.admin.css @@ -219,7 +219,7 @@ table.system-status-report .status-title { .system-themes-list { margin-bottom: 20px; } -.system-themes-list-disabled { +.system-themes-list-uninstalled { border-top: 1px solid #cdcdcd; padding-top: 20px; } @@ -241,8 +241,8 @@ table.system-status-report .status-title { .theme-default .screenshot { border: 1px solid #aaa; } -.system-themes-list-disabled .screenshot, -.system-themes-list-disabled .no-screenshot { +.system-themes-list-uninstalled .screenshot, +.system-themes-list-uninstalled .no-screenshot { max-width: 194px; height: auto; } @@ -257,31 +257,31 @@ table.system-status-report .status-title { * Theme display without vertical toolbar. */ @media screen and (min-width: 45em) { - body:not(.toolbar-vertical) .system-themes-list-enabled .screenshot, - body:not(.toolbar-vertical) .system-themes-list-enabled .no-screenshot { + body:not(.toolbar-vertical) .system-themes-list-installed .screenshot, + body:not(.toolbar-vertical) .system-themes-list-installed .no-screenshot { float: left; /* LTR */ margin: 0 20px 0 0; /* LTR */ width: 294px; } - [dir="rtl"] body:not(.toolbar-vertical) .system-themes-list-enabled .screenshot, - [dir="rtl"] body:not(.toolbar-vertical) .system-themes-list-enabled .no-screenshot { + [dir="rtl"] body:not(.toolbar-vertical) .system-themes-list-installed .screenshot, + [dir="rtl"] body:not(.toolbar-vertical) .system-themes-list-installed .no-screenshot { float: right; margin: 0 0 0 20px; } - body:not(.toolbar-vertical) .system-themes-list-enabled h3 { + body:not(.toolbar-vertical) .system-themes-list-installed h3 { margin-top: 0; } - body:not(.toolbar-vertical) .system-themes-list-disabled .theme-selector { + body:not(.toolbar-vertical) .system-themes-list-uninstalled .theme-selector { box-sizing: border-box; width: 31.25%; float: left; /* LTR */ padding: 20px 20px 20px 0; /* LTR */ } - [dir="rtl"] body:not(.toolbar-vertical) .system-themes-list-disabled .theme-selector { + [dir="rtl"] body:not(.toolbar-vertical) .system-themes-list-uninstalled .theme-selector { float: right; padding: 20px 0 20px 20px; } - body:not(.toolbar-vertical) .system-themes-list-disabled .theme-info { + body:not(.toolbar-vertical) .system-themes-list-uninstalled .theme-info { min-height: 170px; } } @@ -290,35 +290,35 @@ table.system-status-report .status-title { * Theme display with vertical toolbar. */ @media screen and (min-width: 60em) { - .toolbar-vertical .system-themes-list-enabled .screenshot, - .toolbar-vertical .system-themes-list-enabled .no-screenshot { + .toolbar-vertical .system-themes-list-installed .screenshot, + .toolbar-vertical .system-themes-list-installed .no-screenshot { float: left; /* LTR */ margin: 0 20px 0 0; /* LTR */ width: 294px; } - [dir="rtl"] .toolbar-vertical .system-themes-list-enabled .screenshot, - [dir="rtl"] .toolbar-vertical .system-themes-list-enabled .no-screenshot { + [dir="rtl"] .toolbar-vertical .system-themes-list-installed .screenshot, + [dir="rtl"] .toolbar-vertical .system-themes-list-installed .no-screenshot { float: right; margin: 0 0 0 20px; } - .toolbar-vertical .system-themes-list-enabled h3 { + .toolbar-vertical .system-themes-list-installed h3 { margin-top: 0; } - .toolbar-vertical .system-themes-list-disabled .theme-selector { + .toolbar-vertical .system-themes-list-uninstalled .theme-selector { box-sizing: border-box; width: 31.25%; float: left; /* LTR */ padding: 20px 20px 20px 0; /* LTR */ } - [dir="rtl"] .toolbar-vertical .system-themes-list-disabled .theme-selector { + [dir="rtl"] .toolbar-vertical .system-themes-list-uninstalled .theme-selector { float: right; padding: 20px 0 20px 20px; } - .toolbar-vertical .system-themes-list-disabled .theme-info { + .toolbar-vertical .system-themes-list-uninstalled .theme-info { min-height: 170px; } } -.system-themes-list-enabled .theme-info { +.system-themes-list-installed .theme-info { max-width: 940px; } diff --git a/core/modules/system/src/Controller/SystemController.php b/core/modules/system/src/Controller/SystemController.php index 605b0a90d7d1a66e0988b40989bb615f420d1ee5..4f1b2f18a73f0c1cacbc5e5c5650cf47d634b2fe 100644 --- a/core/modules/system/src/Controller/SystemController.php +++ b/core/modules/system/src/Controller/SystemController.php @@ -191,7 +191,7 @@ public function themesPage() { uasort($themes, 'system_sort_modules_by_info_name'); $theme_default = $config->get('default'); - $theme_groups = array('enabled' => array(), 'disabled' => array()); + $theme_groups = array('installed' => array(), 'uninstalled' => array()); $admin_theme = $config->get('admin'); $admin_theme_options = array(); @@ -251,10 +251,10 @@ public function themesPage() { if (!$theme->is_default) { if ($theme->getName() != $admin_theme) { $theme->operations[] = array( - 'title' => $this->t('Disable'), - 'route_name' => 'system.theme_disable', + 'title' => $this->t('Uninstall'), + 'route_name' => 'system.theme_uninstall', 'query' => $query, - 'attributes' => array('title' => $this->t('Disable !theme theme', array('!theme' => $theme->info['name']))), + 'attributes' => array('title' => $this->t('Uninstall !theme theme', array('!theme' => $theme->info['name']))), ); } $theme->operations[] = array( @@ -268,16 +268,16 @@ public function themesPage() { } else { $theme->operations[] = array( - 'title' => $this->t('Enable'), - 'route_name' => 'system.theme_enable', + 'title' => $this->t('Install'), + 'route_name' => 'system.theme_install', 'query' => $query, - 'attributes' => array('title' => $this->t('Enable !theme theme', array('!theme' => $theme->info['name']))), + 'attributes' => array('title' => $this->t('Install !theme theme', array('!theme' => $theme->info['name']))), ); $theme->operations[] = array( - 'title' => $this->t('Enable and set as default'), + 'title' => $this->t('Install and set as default'), 'route_name' => 'system.theme_set_default', 'query' => $query, - 'attributes' => array('title' => $this->t('Enable !theme as default theme', array('!theme' => $theme->info['name']))), + 'attributes' => array('title' => $this->t('Install !theme as default theme', array('!theme' => $theme->info['name']))), ); } } @@ -294,19 +294,19 @@ public function themesPage() { $theme->notes[] = $this->t('admin theme'); } - // Sort enabled and disabled themes into their own groups. - $theme_groups[$theme->status ? 'enabled' : 'disabled'][] = $theme; + // Sort installed and uninstalled themes into their own groups. + $theme_groups[$theme->status ? 'installed' : 'uninstalled'][] = $theme; } // There are two possible theme groups. $theme_group_titles = array( - 'enabled' => $this->formatPlural(count($theme_groups['enabled']), 'Enabled theme', 'Enabled themes'), + 'installed' => $this->formatPlural(count($theme_groups['installed']), 'Installed theme', 'Installed themes'), ); - if (!empty($theme_groups['disabled'])) { - $theme_group_titles['disabled'] = $this->formatPlural(count($theme_groups['disabled']), 'Disabled theme', 'Disabled themes'); + if (!empty($theme_groups['uninstalled'])) { + $theme_group_titles['uninstalled'] = $this->formatPlural(count($theme_groups['uninstalled']), 'Uninstalled theme', 'Uninstalled themes'); } - uasort($theme_groups['enabled'], 'system_sort_themes'); + uasort($theme_groups['installed'], 'system_sort_themes'); $this->moduleHandler()->alter('system_themes_page', $theme_groups); $build = array(); diff --git a/core/modules/system/src/Controller/ThemeController.php b/core/modules/system/src/Controller/ThemeController.php index 51d91f978bc1699bd1c90800dfcde3d51056be5d..fb988425559d40a6cb0fcc34211ab3461c863d79 100644 --- a/core/modules/system/src/Controller/ThemeController.php +++ b/core/modules/system/src/Controller/ThemeController.php @@ -57,7 +57,7 @@ public static function create(ContainerInterface $container) { } /** - * Disables a theme. + * Uninstalls a theme. * * @param \Symfony\Component\HttpFoundation\Request $request * A request object containing a theme name and a valid token. @@ -69,7 +69,7 @@ public static function create(ContainerInterface $container) { * Throws access denied when no theme or token is set in the request or when * the token is invalid. */ - public function disable(Request $request) { + public function uninstall(Request $request) { $theme = $request->get('theme'); $config = $this->config('system.theme'); @@ -79,13 +79,13 @@ public function disable(Request $request) { // Check if the specified theme is one recognized by the system. if (!empty($themes[$theme])) { - // Do not disable the default or admin theme. + // Do not uninstall the default or admin theme. if ($theme === $config->get('default') || $theme === $config->get('admin')) { - drupal_set_message($this->t('%theme is the default theme and cannot be disabled.', array('%theme' => $themes[$theme]->info['name'])), 'error'); + drupal_set_message($this->t('%theme is the default theme and cannot be uninstalled.', array('%theme' => $themes[$theme]->info['name'])), 'error'); } else { - $this->themeHandler->disable(array($theme)); - drupal_set_message($this->t('The %theme theme has been disabled.', array('%theme' => $themes[$theme]->info['name']))); + $this->themeHandler->uninstall(array($theme)); + drupal_set_message($this->t('The %theme theme has been uninstalled.', array('%theme' => $themes[$theme]->info['name']))); } } else { @@ -99,7 +99,7 @@ public function disable(Request $request) { } /** - * Enables a theme. + * Installs a theme. * * @param \Symfony\Component\HttpFoundation\Request $request * A request object containing a theme name and a valid token. @@ -111,13 +111,13 @@ public function disable(Request $request) { * Throws access denied when no theme or token is set in the request or when * the token is invalid. */ - public function enable(Request $request) { + public function install(Request $request) { $theme = $request->get('theme'); if (isset($theme)) { - if ($this->themeHandler->enable(array($theme))) { + if ($this->themeHandler->install(array($theme))) { $themes = $this->themeHandler->listInfo(); - drupal_set_message($this->t('The %theme theme has been enabled.', array('%theme' => $themes[$theme]->info['name']))); + drupal_set_message($this->t('The %theme theme has been installed.', array('%theme' => $themes[$theme]->info['name']))); } else { drupal_set_message($this->t('The %theme theme was not found.', array('%theme' => $theme)), 'error'); @@ -150,8 +150,8 @@ public function setDefaultTheme(Request $request) { $themes = $this->themeHandler->listInfo(); // Check if the specified theme is one recognized by the system. - // Or try to enable the theme. - if (isset($themes[$theme]) || $this->themeHandler->enable(array($theme))) { + // Or try to install the theme. + if (isset($themes[$theme]) || $this->themeHandler->install(array($theme))) { $themes = $this->themeHandler->listInfo(); // Set the default theme. diff --git a/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php index b65628abc00067b18e8311223d5c947bf8bb7441..383f7ac97d8631fd9f6f5ba03aa5a1ae8dffe42a 100644 --- a/core/modules/system/src/Form/ThemeSettingsForm.php +++ b/core/modules/system/src/Form/ThemeSettingsForm.php @@ -71,7 +71,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $theme = $themes = list_themes(); - // Deny access if the theme is disabled or not found. + // Deny access if the theme is not installed or not found. if (!empty($theme) && (empty($themes[$theme]) || !$themes[$theme]->status)) { throw new NotFoundHttpException(); } diff --git a/core/modules/system/src/Tests/Ajax/FrameworkTest.php b/core/modules/system/src/Tests/Ajax/FrameworkTest.php index 340b59747cbac1debee815080a5aafca0932d869..0928c2ac5b3dd5950eced4d72bd5f3838fbaf321 100644 --- a/core/modules/system/src/Tests/Ajax/FrameworkTest.php +++ b/core/modules/system/src/Tests/Ajax/FrameworkTest.php @@ -218,7 +218,7 @@ public function testCurrentPathChange() { public function testLazyLoadOverriddenCSS() { // The test theme overrides system.module.css without an implementation, // thereby removing it. - theme_enable(array('test_theme')); + \Drupal::service('theme_handler')->install(array('test_theme')); \Drupal::config('system.theme') ->set('default', 'test_theme') ->save(); diff --git a/core/modules/system/src/Tests/Batch/PageTest.php b/core/modules/system/src/Tests/Batch/PageTest.php index 1a30c6ce3215b266588dc9aafc30d2e2340590f6..42800b76c70374d821bb5e4be367a154038e2363 100644 --- a/core/modules/system/src/Tests/Batch/PageTest.php +++ b/core/modules/system/src/Tests/Batch/PageTest.php @@ -29,7 +29,7 @@ class PageTest extends WebTestBase { function testBatchProgressPageTheme() { // Make sure that the page which starts the batch (an administrative page) // is using a different theme than would normally be used by the batch API. - $this->container->get('theme_handler')->enable(array('seven', 'bartik')); + $this->container->get('theme_handler')->install(array('seven', 'bartik')); $this->container->get('config.factory')->get('system.theme') ->set('default', 'bartik') ->set('admin', 'seven') diff --git a/core/modules/system/src/Tests/Common/AlterTest.php b/core/modules/system/src/Tests/Common/AlterTest.php index 40b3193985f18fe01dcf3b5fda4c4c7fb0c07837..a0eb95b1186c9d3c1a2a26f26f99f89b4b1a8f42 100644 --- a/core/modules/system/src/Tests/Common/AlterTest.php +++ b/core/modules/system/src/Tests/Common/AlterTest.php @@ -29,7 +29,7 @@ class AlterTest extends WebTestBase { function testDrupalAlter() { // This test depends on Bartik, so make sure that it is always the current // active theme. - \Drupal::service('theme_handler')->enable(array('bartik')); + \Drupal::service('theme_handler')->install(array('bartik')); \Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme('bartik')); $array = array('foo' => 'bar'); diff --git a/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php b/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php index 26dd6eaaa1c20afcfa6064aa48d268600854e32c..a8d04877008618b5aa01956fedf99052460abd76 100644 --- a/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php +++ b/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php @@ -26,7 +26,7 @@ class CurrentThemeConditionTest extends KernelTestBase { * Tests the current theme condition. */ public function testCurrentTheme() { - \Drupal::service('theme_handler')->enable(array('test_theme')); + \Drupal::service('theme_handler')->install(array('test_theme')); $manager = \Drupal::service('plugin.manager.condition'); /** @var $condition \Drupal\Core\Condition\ConditionInterface */ diff --git a/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php b/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php index f652bfdc495b87ad6663b185a7fc8e69f03ccdf1..619736b6a479b3d8c7265a1f670145b66d6096ac 100644 --- a/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php +++ b/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php @@ -12,7 +12,7 @@ use Drupal\simpletest\DrupalUnitTestBase; /** - * Tests installing/enabling, disabling, and uninstalling of themes. + * Tests installing and uninstalling of themes. * * @group Extension */ @@ -39,11 +39,10 @@ protected function setUp() { } /** - * Verifies that no themes are installed/enabled/disabled by default. + * Verifies that no themes are installed by default. */ function testEmpty() { $this->assertFalse($this->extensionConfig()->get('theme')); - $this->assertFalse($this->extensionConfig()->get('disabled.theme')); $this->assertFalse(array_keys($this->themeHandler()->listInfo())); $this->assertFalse(array_keys(system_list('theme'))); @@ -56,18 +55,17 @@ function testEmpty() { } /** - * Tests enabling a theme. + * Tests installing a theme. */ - function testEnable() { + function testInstall() { $name = 'test_basetheme'; $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name])); - $this->themeHandler()->enable(array($name)); + $this->themeHandler()->install(array($name)); $this->assertIdentical($this->extensionConfig()->get("theme.$name"), 0); - $this->assertNull($this->extensionConfig()->get("disabled.theme.$name")); $themes = $this->themeHandler()->listInfo(); $this->assertTrue(isset($themes[$name])); @@ -82,22 +80,22 @@ function testEnable() { } /** - * Tests enabling a sub-theme. + * Tests installing a sub-theme. */ - function testEnableSubTheme() { + function testInstallSubTheme() { $name = 'test_subtheme'; $base_name = 'test_basetheme'; $themes = $this->themeHandler()->listInfo(); $this->assertFalse(array_keys($themes)); - $this->themeHandler()->enable(array($name)); + $this->themeHandler()->install(array($name)); $themes = $this->themeHandler()->listInfo(); $this->assertTrue(isset($themes[$name])); $this->assertTrue(isset($themes[$base_name])); - $this->themeHandler()->disable(array($name)); + $this->themeHandler()->uninstall(array($name)); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name])); @@ -105,17 +103,17 @@ function testEnableSubTheme() { } /** - * Tests enabling a non-existing theme. + * Tests installing a non-existing theme. */ - function testEnableNonExisting() { + function testInstallNonExisting() { $name = 'non_existing_theme'; $themes = $this->themeHandler()->listInfo(); $this->assertFalse(array_keys($themes)); try { - $message = 'ThemeHandler::enable() throws InvalidArgumentException upon enabling a non-existing theme.'; - $this->themeHandler()->enable(array($name)); + $message = 'ThemeHandler::install() throws InvalidArgumentException upon installing a non-existing theme.'; + $this->themeHandler()->install(array($name)); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -127,14 +125,14 @@ function testEnableNonExisting() { } /** - * Tests enabling a theme with a too long name. + * Tests installing a theme with a too long name. */ - function testEnableNameTooLong() { + function testInstallNameTooLong() { $name = 'test_theme_having_veery_long_name_which_is_too_long'; try { - $message = 'ThemeHandler::enable() throws ExtensionNameLengthException upon enabling a theme with a too long name.'; - $this->themeHandler()->enable(array($name)); + $message = 'ThemeHandler::install() throws ExtensionNameLengthException upon installing a theme with a too long name.'; + $this->themeHandler()->install(array($name)); $this->fail($message); } catch (ExtensionNameLengthException $e) { @@ -143,79 +141,12 @@ function testEnableNameTooLong() { } /** - * Tests disabling a theme. + * Tests uninstalling the default theme. */ - function testDisable() { - $name = 'test_basetheme'; - $this->themeHandler()->enable(array($name)); - - // Prime the relevant drupal_static()s. - $this->assertEqual(array_keys(system_list('theme')), array($name)); - $this->assertIdentical(theme_get_setting('features.favicon', $name), FALSE); - - $this->themeHandler()->disable(array($name)); - - $this->assertIdentical($this->extensionConfig()->get('theme'), array()); - $this->assertIdentical($this->extensionConfig()->get("disabled.theme.$name"), 0); - - $this->assertFalse(array_keys($this->themeHandler()->listInfo())); - $this->assertFalse(array_keys(system_list('theme'))); - - // Verify that test_basetheme.settings no longer applies, even though the - // configuration still exists. - $this->assertIdentical(theme_get_setting('features.favicon', $name), TRUE); - $this->assertNull(theme_get_setting('base', $name)); - $this->assertNull(theme_get_setting('override', $name)); - - // The theme is not uninstalled, so its configuration must still exist. - $this->assertTrue($this->config("$name.settings")->get()); - } - - /** - * Tests disabling and enabling a theme. - * - * Verifies that - * - themes can be re-enabled - * - default configuration is not re-imported upon re-enabling an already - * installed theme. - */ - function testDisableEnable() { - $name = 'test_basetheme'; - - $this->themeHandler()->enable(array($name)); - $this->themeHandler()->disable(array($name)); - - $this->assertIdentical($this->config("$name.settings")->get('base'), 'only'); - $this->assertIdentical($this->config('core.date_format.fancy')->get('label'), 'Fancy date'); - - // Default configuration never overwrites custom configuration, so just - // changing values in existing configuration will cause ConfigInstaller to - // simply skip those files. To ensure that no default configuration is - // re-imported, the custom configuration has to be deleted. - $this->configStorage()->delete("$name.settings"); - $this->configStorage()->delete('core.date_format.fancy'); - // Reflect direct storage operations in ConfigFactory. - $this->container->get('config.factory')->reset(); - - $this->themeHandler()->enable(array($name)); - - $themes = $this->themeHandler()->listInfo(); - $this->assertTrue(isset($themes[$name])); - $this->assertEqual($themes[$name]->getName(), $name); - - $this->assertEqual(array_keys(system_list('theme')), array_keys($themes)); - - $this->assertFalse($this->config("$name.settings")->get()); - $this->assertNull($this->config('core.date_format.fancy')->get('label')); - } - - /** - * Tests disabling the default theme. - */ - function testDisableDefault() { + function testUninstallDefault() { $name = 'stark'; $other_name = 'bartik'; - $this->themeHandler()->enable(array($name, $other_name)); + $this->themeHandler()->install(array($name, $other_name)); $this->themeHandler()->setDefault($name); $themes = $this->themeHandler()->listInfo(); @@ -223,8 +154,8 @@ function testDisableDefault() { $this->assertTrue(isset($themes[$other_name])); try { - $message = 'ThemeHandler::disable() throws InvalidArgumentException upon disabling default theme.'; - $this->themeHandler()->disable(array($name)); + $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon disabling default theme.'; + $this->themeHandler()->uninstall(array($name)); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -237,12 +168,12 @@ function testDisableDefault() { } /** - * Tests disabling the admin theme. + * Tests uninstalling the admin theme. */ - function testDisableAdmin() { + function testUninstallAdmin() { $name = 'stark'; $other_name = 'bartik'; - $this->themeHandler()->enable(array($name, $other_name)); + $this->themeHandler()->install(array($name, $other_name)); $this->config('system.theme')->set('admin', $name)->save(); $themes = $this->themeHandler()->listInfo(); @@ -250,8 +181,8 @@ function testDisableAdmin() { $this->assertTrue(isset($themes[$other_name])); try { - $message = 'ThemeHandler::disable() throws InvalidArgumentException upon disabling admin theme.'; - $this->themeHandler()->disable(array($name)); + $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon disabling admin theme.'; + $this->themeHandler()->uninstall(array($name)); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -264,14 +195,14 @@ function testDisableAdmin() { } /** - * Tests disabling a sub-theme. + * Tests uninstalling a sub-theme. */ - function testDisableSubTheme() { + function testUninstallSubTheme() { $name = 'test_subtheme'; $base_name = 'test_basetheme'; - $this->themeHandler()->enable(array($name)); - $this->themeHandler()->disable(array($name)); + $this->themeHandler()->install(array($name)); + $this->themeHandler()->uninstall(array($name)); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name])); @@ -279,17 +210,17 @@ function testDisableSubTheme() { } /** - * Tests disabling a base theme before its sub-theme. + * Tests uninstalling a base theme before its sub-theme. */ - function testDisableBaseBeforeSubTheme() { + function testUninstallBaseBeforeSubTheme() { $name = 'test_basetheme'; $sub_name = 'test_subtheme'; - $this->themeHandler()->enable(array($sub_name)); + $this->themeHandler()->install(array($sub_name)); try { - $message = 'ThemeHandler::disable() throws InvalidArgumentException upon disabling base theme before sub theme.'; - $this->themeHandler()->disable(array($name)); + $message = 'ThemeHandler::install() throws InvalidArgumentException upon uninstalling base theme before sub theme.'; + $this->themeHandler()->uninstall(array($name)); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -300,8 +231,8 @@ function testDisableBaseBeforeSubTheme() { $this->assertTrue(isset($themes[$name])); $this->assertTrue(isset($themes[$sub_name])); - // Verify that disabling both at the same time works. - $this->themeHandler()->disable(array($name, $sub_name)); + // Verify that uninstalling both at the same time works. + $this->themeHandler()->uninstall(array($name, $sub_name)); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name])); @@ -309,17 +240,17 @@ function testDisableBaseBeforeSubTheme() { } /** - * Tests disabling a non-existing theme. + * Tests uninstalling a non-existing theme. */ - function testDisableNonExisting() { + function testUninstallNonExisting() { $name = 'non_existing_theme'; $themes = $this->themeHandler()->listInfo(); $this->assertFalse(array_keys($themes)); try { - $message = 'ThemeHandler::disable() throws InvalidArgumentException upon disabling a non-existing theme.'; - $this->themeHandler()->disable(array($name)); + $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon uninstalling a non-existing theme.'; + $this->themeHandler()->uninstall(array($name)); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -330,6 +261,47 @@ function testDisableNonExisting() { $this->assertFalse(array_keys($themes)); } + /** + * Tests uninstalling a theme. + */ + function testUninstall() { + $name = 'test_basetheme'; + + $this->themeHandler()->install(array($name)); + $this->assertTrue($this->config("$name.settings")->get()); + + $this->themeHandler()->uninstall(array($name)); + + $this->assertFalse(array_keys($this->themeHandler()->listInfo())); + $this->assertFalse(array_keys(system_list('theme'))); + + $this->assertFalse($this->config("$name.settings")->get()); + + // Ensure that the uninstalled theme can be installed again. + $this->themeHandler()->install(array($name)); + $themes = $this->themeHandler()->listInfo(); + $this->assertTrue(isset($themes[$name])); + $this->assertEqual($themes[$name]->getName(), $name); + $this->assertEqual(array_keys(system_list('theme')), array_keys($themes)); + $this->assertTrue($this->config("$name.settings")->get()); + } + + /** + * Tests uninstalling a theme that is not installed. + */ + function testUninstallNotInstalled() { + $name = 'test_basetheme'; + + try { + $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon uninstalling a theme that is not installed.'; + $this->themeHandler()->uninstall(array($name)); + $this->fail($message); + } + catch (\InvalidArgumentException $e) { + $this->pass(get_class($e) . ': ' . $e->getMessage()); + } + } + /** * Tests that theme info can be altered by a module. * @@ -340,7 +312,7 @@ function testThemeInfoAlter() { $this->container->get('state')->set('module_test.hook_system_info_alter', TRUE); $module_handler = $this->container->get('module_handler'); - $this->themeHandler()->enable(array($name)); + $this->themeHandler()->install(array($name)); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name]->info['regions']['test_region'])); diff --git a/core/modules/system/src/Tests/Menu/MenuRouterTest.php b/core/modules/system/src/Tests/Menu/MenuRouterTest.php index c49e3fd559fce7b26530e5713414c9a33e918d05..3ad879cd9a3173171e20a0e01b25fffe0f75c1b5 100644 --- a/core/modules/system/src/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/src/Tests/Menu/MenuRouterTest.php @@ -242,12 +242,12 @@ public function testThemeIntegration() { $this->admin_theme = 'seven'; $theme_handler = $this->container->get('theme_handler'); - $theme_handler->enable(array($this->default_theme, $this->admin_theme)); + $theme_handler->install(array($this->default_theme, $this->admin_theme)); $this->container->get('config.factory')->get('system.theme') ->set('default', $this->default_theme) ->set('admin', $this->admin_theme) ->save(); - $theme_handler->disable(array('stark')); + $theme_handler->uninstall(array('stark')); $this->doTestThemeCallbackMaintenanceMode(); @@ -294,20 +294,20 @@ protected function doTestThemeCallbackMaintenanceMode() { * Test the theme negotiation when it is set to use an optional theme. */ protected function doTestThemeCallbackOptionalTheme() { - // Request a theme that is not enabled. + // Request a theme that is not installed. $this->drupalGet('menu-test/theme-callback/use-stark-theme'); - $this->assertText('Active theme: bartik. Actual theme: bartik.', 'The theme negotiation system falls back on the default theme when a theme that is not enabled is requested.'); + $this->assertText('Active theme: bartik. Actual theme: bartik.', 'The theme negotiation system falls back on the default theme when a theme that is not installed is requested.'); $this->assertRaw('bartik/css/style.css', "The default theme's CSS appears on the page."); - // Now enable the theme and request it again. + // Now install the theme and request it again. $theme_handler = $this->container->get('theme_handler'); - $theme_handler->enable(array('stark')); + $theme_handler->install(array('stark')); $this->drupalGet('menu-test/theme-callback/use-stark-theme'); - $this->assertText('Active theme: stark. Actual theme: stark.', 'The theme negotiation system uses an optional theme once it has been enabled.'); + $this->assertText('Active theme: stark. Actual theme: stark.', 'The theme negotiation system uses an optional theme once it has been installed.'); $this->assertRaw('stark/css/layout.css', "The optional theme's CSS appears on the page."); - $theme_handler->disable(array('stark')); + $theme_handler->uninstall(array('stark')); } /** diff --git a/core/modules/system/src/Tests/System/ThemeTest.php b/core/modules/system/src/Tests/System/ThemeTest.php index 6912afb48e2717dc65d2ea6064aaa8e18cce474f..80a3c43bf265d76c06f723fb1f8dd0ae982f1f5f 100644 --- a/core/modules/system/src/Tests/System/ThemeTest.php +++ b/core/modules/system/src/Tests/System/ThemeTest.php @@ -41,7 +41,7 @@ protected function setUp() { function testThemeSettings() { // Ensure invalid theme settings form URLs return a proper 404. $this->drupalGet('admin/appearance/settings/bartik'); - $this->assertResponse(404, 'The theme settings form URL for a disabled theme could not be found.'); + $this->assertResponse(404, 'The theme settings form URL for a uninstalled theme could not be found.'); $this->drupalGet('admin/appearance/settings/' . $this->randomMachineName()); $this->assertResponse(404, 'The theme settings form URL for a non-existent theme could not be found.'); @@ -179,9 +179,9 @@ function testThemeSettings() { * Test the administration theme functionality. */ function testAdministrationTheme() { - $this->container->get('theme_handler')->enable(array('seven')); + $this->container->get('theme_handler')->install(array('seven')); - // Enable an administration theme and show it on the node admin pages. + // Install an administration theme and show it on the node admin pages. $edit = array( 'admin_theme' => 'seven', 'use_admin_theme' => TRUE, @@ -238,8 +238,8 @@ function testAdministrationTheme() { * Test switching the default theme. */ function testSwitchDefaultTheme() { - // Enable Bartik and set it as the default theme. - theme_enable(array('bartik')); + // Install Bartik and set it as the default theme. + \Drupal::service('theme_handler')->install(array('bartik')); $this->drupalGet('admin/appearance'); $this->clickLink(t('Set as default')); $this->assertEqual(\Drupal::config('system.theme')->get('default'), 'bartik'); @@ -257,7 +257,7 @@ function testSwitchDefaultTheme() { } /** - * Test that themes can't be enabled when the base theme or engine is missing. + * Test themes can't be installed when the base theme or engine is missing. */ function testInvalidTheme() { // theme_page_test_system_info_alter() un-hides all hidden themes. diff --git a/core/modules/system/src/Tests/Theme/EnginePhpTemplateTest.php b/core/modules/system/src/Tests/Theme/EnginePhpTemplateTest.php index 4108d6163ee7f63ce1124dc577b3964341d881fd..8cbde63bb250a1bad1befdd333178334cecf8a80 100644 --- a/core/modules/system/src/Tests/Theme/EnginePhpTemplateTest.php +++ b/core/modules/system/src/Tests/Theme/EnginePhpTemplateTest.php @@ -25,7 +25,7 @@ class EnginePhpTemplateTest extends WebTestBase { protected function setUp() { parent::setUp(); - theme_enable(array('test_theme_phptemplate')); + \Drupal::service('theme_handler')->install(array('test_theme_phptemplate')); } /** diff --git a/core/modules/system/src/Tests/Theme/EngineTwigTest.php b/core/modules/system/src/Tests/Theme/EngineTwigTest.php index c03f16b9b9504695715b4155eb15a620fb378f46..13f947e0de4162ecbcf47d0f33e6e80e5437dc58 100644 --- a/core/modules/system/src/Tests/Theme/EngineTwigTest.php +++ b/core/modules/system/src/Tests/Theme/EngineTwigTest.php @@ -25,7 +25,7 @@ class EngineTwigTest extends WebTestBase { protected function setUp() { parent::setUp(); - theme_enable(array('test_theme')); + \Drupal::service('theme_handler')->install(array('test_theme')); } /** diff --git a/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php b/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php index 26aa7ec5b54bfa7840d56f2add0d2a1924c77634..8454fe99382f3d6541a39a378e3120d5172e237e 100644 --- a/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php +++ b/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php @@ -78,10 +78,10 @@ class EntityFilteringThemeTest extends WebTestBase { protected function setUp() { parent::setUp(); - // Enable all available non-testing themes. + // Install all available non-testing themes. $listing = new ExtensionDiscovery(); $this->themes = $listing->scan('theme', FALSE); - theme_enable(array_keys($this->themes)); + \Drupal::service('theme_handler')->install(array_keys($this->themes)); // Create a test user. $this->user = $this->drupalCreateUser(array('access content', 'access user profiles')); diff --git a/core/modules/system/src/Tests/Theme/ThemeInfoTest.php b/core/modules/system/src/Tests/Theme/ThemeInfoTest.php index 7848ef30ce8b4a0f1326c9d81d1cb6b7f48b1a0f..f35ef89208d13c3a7d4f747f52fbafd889014fd2 100644 --- a/core/modules/system/src/Tests/Theme/ThemeInfoTest.php +++ b/core/modules/system/src/Tests/Theme/ThemeInfoTest.php @@ -59,7 +59,7 @@ protected function setUp() { * Tests stylesheets-override and stylesheets-remove. */ function testStylesheets() { - $this->themeHandler->enable(array('test_basetheme', 'test_subtheme')); + $this->themeHandler->install(array('test_basetheme', 'test_subtheme')); \Drupal::config('system.theme') ->set('default', 'test_subtheme') ->save(); @@ -92,7 +92,7 @@ function testStylesheets() { * Tests that changes to the info file are picked up. */ public function testChanges() { - $this->themeHandler->enable(array('test_theme')); + $this->themeHandler->install(array('test_theme')); $this->themeHandler->setDefault('test_theme'); $this->themeManager->resetActiveTheme(); diff --git a/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php b/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php index 698b66d478a9d218e9ede37ff890cf900b8b0dc6..927592246c18eba924eb3c28225e5115dc251092 100644 --- a/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php +++ b/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php @@ -50,7 +50,7 @@ function testDefaultConfig() { $name = 'test_basetheme'; $path = $this->availableThemes[$name]->getPath(); $this->assertTrue(file_exists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml")); - $this->container->get('theme_handler')->enable(array($name)); + $this->container->get('theme_handler')->install(array($name)); $this->assertIdentical(theme_get_setting('base', $name), 'only'); } @@ -61,7 +61,7 @@ function testNoDefaultConfig() { $name = 'stark'; $path = $this->availableThemes[$name]->getPath(); $this->assertFalse(file_exists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml")); - $this->container->get('theme_handler')->enable(array($name)); + $this->container->get('theme_handler')->install(array($name)); $this->assertNotNull(theme_get_setting('features.favicon', $name)); } diff --git a/core/modules/system/src/Tests/Theme/ThemeSuggestionsAlterTest.php b/core/modules/system/src/Tests/Theme/ThemeSuggestionsAlterTest.php index 54fdfce76e3d9d2050c9ad6d118a3956622932a8..6bf00f4df9ca13d892633c373aaa83b41641ae1b 100644 --- a/core/modules/system/src/Tests/Theme/ThemeSuggestionsAlterTest.php +++ b/core/modules/system/src/Tests/Theme/ThemeSuggestionsAlterTest.php @@ -26,7 +26,7 @@ class ThemeSuggestionsAlterTest extends WebTestBase { protected function setUp() { parent::setUp(); - theme_enable(array('test_theme')); + \Drupal::service('theme_handler')->install(array('test_theme')); } /** @@ -36,7 +36,7 @@ function testTemplateSuggestions() { $this->drupalGet('theme-test/suggestion-provided'); $this->assertText('Template for testing suggestions provided by the module declaring the theme hook.'); - // Enable test_theme, it contains a template suggested by theme_test.module + // Install test_theme, it contains a template suggested by theme_test.module // in theme_test_theme_suggestions_theme_test_suggestion_provided(). \Drupal::config('system.theme') ->set('default', 'test_theme') @@ -53,7 +53,7 @@ function testGeneralSuggestionsAlter() { $this->drupalGet('theme-test/general-suggestion-alter'); $this->assertText('Original template for testing hook_theme_suggestions_alter().'); - // Enable test_theme and test that themes can alter template suggestions. + // Install test_theme and test that themes can alter template suggestions. \Drupal::config('system.theme') ->set('default', 'test_theme') ->save(); @@ -75,7 +75,7 @@ function testTemplateSuggestionsAlter() { $this->drupalGet('theme-test/suggestion-alter'); $this->assertText('Original template for testing hook_theme_suggestions_HOOK_alter().'); - // Enable test_theme and test that themes can alter template suggestions. + // Install test_theme and test that themes can alter template suggestions. \Drupal::config('system.theme') ->set('default', 'test_theme') ->save(); @@ -122,7 +122,7 @@ function testThemeFunctionSuggestionsAlter() { $this->drupalGet('theme-test/function-suggestion-alter'); $this->assertText('Original theme function.'); - // Enable test_theme and test that themes can alter theme suggestions. + // Install test_theme and test that themes can alter theme suggestions. \Drupal::config('system.theme') ->set('default', 'test_theme') ->save(); @@ -163,7 +163,7 @@ public function testSuggestionsAlterInclude() { * hook_theme_suggestions_HOOK_alter() within an extension (module or theme). */ function testExecutionOrder() { - // Enable our test theme and module. + // Install our test theme and module. \Drupal::config('system.theme') ->set('default', 'test_theme') ->save(); diff --git a/core/modules/system/src/Tests/Theme/ThemeTest.php b/core/modules/system/src/Tests/Theme/ThemeTest.php index 56050f789b60677a16a9401e4f62bbd8911a9d6f..bee40f1c03d02f5100700dc1f2dbef2d0cdabc8f 100644 --- a/core/modules/system/src/Tests/Theme/ThemeTest.php +++ b/core/modules/system/src/Tests/Theme/ThemeTest.php @@ -27,7 +27,7 @@ class ThemeTest extends WebTestBase { protected function setUp() { parent::setUp(); - theme_enable(array('test_theme')); + \Drupal::service('theme_handler')->install(array('test_theme')); } /** @@ -199,11 +199,12 @@ function testFunctionOverride() { */ function testListThemes() { $theme_handler = $this->container->get('theme_handler'); - $theme_handler->enable(array('test_subtheme')); + $theme_handler->install(array('test_subtheme')); $themes = $theme_handler->listInfo(); - // Check if drupal_theme_access() retrieves enabled themes properly from list_themes(). - $this->assertTrue(drupal_theme_access('test_theme'), 'Enabled theme detected'); + // Check if drupal_theme_access() retrieves installed themes properly from + // list_themes(). + $this->assertTrue(drupal_theme_access('test_theme'), 'Installed theme detected'); // Check for base theme and subtheme lists. $base_theme_list = array('test_basetheme' => 'Theme test base theme'); @@ -221,7 +222,7 @@ function testListThemes() { * Test the theme_get_setting() function. */ function testThemeGetSetting() { - $this->container->get('theme_handler')->enable(array('test_subtheme')); + $this->container->get('theme_handler')->install(array('test_subtheme')); \Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme('test_theme')); $this->assertIdentical(theme_get_setting('theme_test_setting'), 'default value', 'theme_get_setting() uses the default theme automatically.'); $this->assertNotEqual(theme_get_setting('subtheme_override', 'test_basetheme'), theme_get_setting('subtheme_override', 'test_subtheme'), 'Base theme\'s default settings values can be overridden by subtheme.'); diff --git a/core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php b/core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php index 102f5429bee4a30ecfe349fee5b236c551fb145c..d5765a0aea1c94e5f113509c1464a625ef3ccab1 100644 --- a/core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php +++ b/core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php @@ -28,7 +28,7 @@ class TwigDebugMarkupTest extends WebTestBase { */ function testTwigDebugMarkup() { $extension = twig_extension(); - theme_enable(array('test_theme')); + \Drupal::service('theme_handler')->install(array('test_theme')); \Drupal::config('system.theme')->set('default', 'test_theme')->save(); $this->drupalCreateContentType(array('type' => 'page')); // Enable debug, rebuild the service container, and clear all caches. diff --git a/core/modules/system/src/Tests/Theme/TwigExtensionTest.php b/core/modules/system/src/Tests/Theme/TwigExtensionTest.php index 05c19d3261aa04e5b14fb4047a880c095b51be66..66ebf475f53886a0cf748b7ea8064e8c1be780fc 100644 --- a/core/modules/system/src/Tests/Theme/TwigExtensionTest.php +++ b/core/modules/system/src/Tests/Theme/TwigExtensionTest.php @@ -25,7 +25,7 @@ class TwigExtensionTest extends WebTestBase { protected function setUp() { parent::setUp(); - theme_enable(array('test_theme')); + \Drupal::service('theme_handler')->install(array('test_theme')); } /** diff --git a/core/modules/system/src/Tests/Theme/TwigNamespaceTest.php b/core/modules/system/src/Tests/Theme/TwigNamespaceTest.php index 499de80a1e1fbd386f7ba35dca0717c62cf7664b..2b759e4e05e48eebefca13d60e0f823dd794e7a9 100644 --- a/core/modules/system/src/Tests/Theme/TwigNamespaceTest.php +++ b/core/modules/system/src/Tests/Theme/TwigNamespaceTest.php @@ -30,7 +30,7 @@ class TwigNamespaceTest extends WebTestBase { protected function setUp() { parent::setUp(); - theme_enable(array('test_theme', 'bartik')); + \Drupal::service('theme_handler')->install(array('test_theme', 'bartik')); $this->twig = \Drupal::service('twig'); } diff --git a/core/modules/system/src/Tests/Theme/TwigSettingsTest.php b/core/modules/system/src/Tests/Theme/TwigSettingsTest.php index c7fec1d56f38ecbc46bd1c71646c05d11f0a52c8..36cc48d903348bd9a62dee92b5f37581d3f7efec 100644 --- a/core/modules/system/src/Tests/Theme/TwigSettingsTest.php +++ b/core/modules/system/src/Tests/Theme/TwigSettingsTest.php @@ -82,7 +82,7 @@ function testTwigDebugOverride() { function testTwigCacheOverride() { $extension = twig_extension(); $theme_handler = $this->container->get('theme_handler'); - $theme_handler->enable(array('test_theme')); + $theme_handler->install(array('test_theme')); $theme_handler->setDefault('test_theme'); // The registry still works on theme globals, so set them here. diff --git a/core/modules/system/src/Tests/Theme/TwigTransTest.php b/core/modules/system/src/Tests/Theme/TwigTransTest.php index 98a6e9fabb2ebdf910f8c543d2ec3a1f9a409971..9983dff8392ebf65526a59515aec1f4b609e6642 100644 --- a/core/modules/system/src/Tests/Theme/TwigTransTest.php +++ b/core/modules/system/src/Tests/Theme/TwigTransTest.php @@ -54,7 +54,7 @@ protected function setUp() { parent::setUp(); // Setup test_theme. - theme_enable(array('test_theme')); + \Drupal::service('theme_handler')->install(array('test_theme')); \Drupal::config('system.theme')->set('default', 'test_theme')->save(); // Create and log in as admin. diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 71297db5f8fea5952b213d7cb481c0e2e92e0082..b859a2803efd10928de7221f2477ef56ef14b67c 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -1397,6 +1397,29 @@ function hook_module_preuninstall($module) { mymodule_cache_clear(); } +/** + * Perform necessary actions when themes are installed. + * + * @param array $themes + * An array of theme names which are installed. + */ +function hook_themes_installed(array $themes) { + // Add some state entries depending on the theme. + foreach ($themes as $theme) { + \Drupal::state()->set('example.' . $theme, 'some-value'); + } +} + +/** + * Perform necessary actions when themes are uninstalled. + */ +function hook_themes_uninstalled(array $themes) { + // Remove some state entries depending on the theme. + foreach ($themes as $theme) { + \Drupal::state()->delete('example.' . $theme); + } +} + /** * Perform necessary actions after modules are uninstalled. * diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 6ca36994703bf27e77c81145b965256e2a3a7149..54deb653453f57305aa0a4bc0d833ebbc017362c 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -80,7 +80,7 @@ function system_help($route_name, RouteMatchInterface $route_match) { $output .= '
' . t('Managing modules') . '
'; $output .= '
' . t('The System module allows users with the appropriate permissions to enable and disable modules on the Modules administration page. Drupal comes with a number of core modules, and each module provides a discrete set of features and may be enabled or disabled depending on the needs of the site. Many additional modules contributed by members of the Drupal community are available for download at the Drupal.org module page.', array('@modules' => url('admin/modules'), '@drupal-modules' => 'http://drupal.org/project/modules')) . '
'; $output .= '
' . t('Managing themes') . '
'; - $output .= '
' . t('The System module allows users with the appropriate permissions to enable and disable themes on the Appearance administration page. Themes determine the design and presentation of your site. Drupal comes packaged with several core themes, and additional contributed themes are available at the Drupal.org theme page.', array('@themes' => url('admin/appearance'), '@drupal-themes' => 'http://drupal.org/project/themes')) . '
'; + $output .= '
' . t('The System module allows users with the appropriate permissions to install and uninstall themes on the Appearance administration page. Themes determine the design and presentation of your site. Drupal comes packaged with several core themes, and additional contributed themes are available at the Drupal.org theme page.', array('@themes' => url('admin/appearance'), '@drupal-themes' => 'http://drupal.org/project/themes')) . '
'; $output .= '
' . t('Managing caching') . '
'; $output .= '
' . t("The System module allows users with the appropriate permissions to manage caching on the Performance settings page. Drupal has a robust caching system that allows the efficient re-use of previously-constructed web pages and web page components. Pages requested by anonymous users are stored in a compressed format; depending on your site configuration and the amount of your web traffic tied to anonymous visitors, the caching system may significantly increase the speed of your site.", array('@cache-settings' => url('admin/config/development/performance'))) . '
'; $output .= '
' . t('Performing system maintenance') . '
'; @@ -335,7 +335,7 @@ function system_stream_wrappers() { } /** - * Menu item access callback - only enabled themes can be accessed. + * Menu item access callback - only installed themes can be accessed. */ function _system_themes_access($theme) { return \Drupal::currentUser()->hasPermission('administer themes') && drupal_theme_access($theme); diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index 80348633ed2b5ad702d071deb235a72eead1c075..6df0e0cca69fafa1c4e289e97556728083675efd 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -253,18 +253,18 @@ system.modules_list_confirm: requirements: _permission: 'administer modules' -system.theme_disable: - path: '/admin/appearance/disable' +system.theme_uninstall: + path: '/admin/appearance/uninstall' defaults: - _controller: 'Drupal\system\Controller\ThemeController::disable' + _controller: 'Drupal\system\Controller\ThemeController::uninstall' requirements: _permission: 'administer themes' _csrf_token: 'TRUE' -system.theme_enable: - path: '/admin/appearance/enable' +system.theme_install: + path: '/admin/appearance/install' defaults: - _controller: 'Drupal\system\Controller\ThemeController::enable' + _controller: 'Drupal\system\Controller\ThemeController::install' requirements: _permission: 'administer themes' _csrf_token: 'TRUE' diff --git a/core/modules/system/templates/system-themes-page.html.twig b/core/modules/system/templates/system-themes-page.html.twig index e40545b156dcbe8d78fdd97f451420bd160f5013..9d55c217165283dfeffac6b9083a718da98c05fa 100644 --- a/core/modules/system/templates/system-themes-page.html.twig +++ b/core/modules/system/templates/system-themes-page.html.twig @@ -8,7 +8,7 @@ * - theme_groups: A list of theme groups. Each theme group contains: * - attributes: HTML attributes specific to this theme group. * - title: Title for the theme group. - * - state: State of the theme group, e.g. enabled or disabled. + * - state: State of the theme group, e.g. installed or uninstalled. * - themes: A list of themes within the theme group. Each theme contains: * - attributes: HTML attributes specific to this theme. * - screenshot: A screenshot representing the theme. diff --git a/core/modules/system/tests/modules/menu_test/src/Theme/TestThemeNegotiator.php b/core/modules/system/tests/modules/menu_test/src/Theme/TestThemeNegotiator.php index 3d3a17ee5b49c1bcb5646f0b669c8a3f7cdb88ed..b4cdd0ad1207f226e146ba72c4f8d2ae166e91de 100644 --- a/core/modules/system/tests/modules/menu_test/src/Theme/TestThemeNegotiator.php +++ b/core/modules/system/tests/modules/menu_test/src/Theme/TestThemeNegotiator.php @@ -34,7 +34,7 @@ public function determineActiveTheme(RouteMatchInterface $route_match) { if ($argument == 'use-admin-theme') { return \Drupal::config('system.theme')->get('admin'); } - // Test using a theme that exists, but may or may not be enabled. + // Test using a theme that exists, but may or may not be installed. elseif ($argument == 'use-stark-theme') { return 'stark'; } diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php index 089334f695a4da311b9c0dfba9e556becd28b726..70426ecdd7f8c77f41fc6bd37a984093ae3beebf 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -468,28 +468,30 @@ function hook_theme_suggestions_HOOK_alter(array &$suggestions, array $variables } /** - * Respond to themes being enabled. + * Respond to themes being installed. * * @param array $theme_list - * Array containing the names of the themes being enabled. + * Array containing the names of the themes being installed. * - * @see theme_enable() + * @see \Drupal\Core\Extension\ThemeHandler::install() */ -function hook_themes_enabled($theme_list) { +function hook_themes_installed($theme_list) { foreach ($theme_list as $theme) { block_theme_initialize($theme); } } /** - * Respond to themes being disabled. + * Respond to themes being uninstalled. * * @param array $theme_list - * Array containing the names of the themes being disabled. + * Array containing the names of the themes being uninstalled. * - * @see theme_disable() + * @see \Drupal\Core\Extension\ThemeHandler::uninstall() */ -function hook_themes_disabled($theme_list) { - // Clear all update module caches. - update_storage_clear(); +function hook_themes_uninstalled(array $themes) { + // Remove some state entries depending on the theme. + foreach ($themes as $theme) { + \Drupal::state()->delete('example.' . $theme); + } } diff --git a/core/modules/taxonomy/src/Tests/ThemeTest.php b/core/modules/taxonomy/src/Tests/ThemeTest.php index 4acef7e463ba1e3754fa32fef71421135ba16591..9ababed458c63eb2534507b9d92b3d11821c4fff 100644 --- a/core/modules/taxonomy/src/Tests/ThemeTest.php +++ b/core/modules/taxonomy/src/Tests/ThemeTest.php @@ -19,7 +19,7 @@ protected function setUp() { // Make sure we are using distinct default and administrative themes for // the duration of these tests. - theme_enable(array('bartik', 'seven')); + \Drupal::service('theme_handler')->install(array('bartik', 'seven')); \Drupal::config('system.theme') ->set('default', 'bartik') ->set('admin', 'seven') diff --git a/core/modules/tour/src/Tests/TourTestBasic.php b/core/modules/tour/src/Tests/TourTestBasic.php index 49dafdcb6459b2cd7e0e9183c1cb5a60cb778967..08680e0bd1bb50b71bb1983226cf57fa8050b8ca 100644 --- a/core/modules/tour/src/Tests/TourTestBasic.php +++ b/core/modules/tour/src/Tests/TourTestBasic.php @@ -49,7 +49,7 @@ protected function setUp() { // Make sure we are using distinct default and administrative themes for // the duration of these tests. - $this->container->get('theme_handler')->enable(array('bartik', 'seven')); + $this->container->get('theme_handler')->install(array('bartik', 'seven')); $this->container->get('config.factory') ->get('system.theme') ->set('default', 'bartik') diff --git a/core/modules/update/src/Tests/UpdateContribTest.php b/core/modules/update/src/Tests/UpdateContribTest.php index 0e547ef2a487af9bb5bc6e59c69e55b6f4ece0f2..622d448f2a0567214d6d45640e30380c1fe1bc16 100644 --- a/core/modules/update/src/Tests/UpdateContribTest.php +++ b/core/modules/update/src/Tests/UpdateContribTest.php @@ -162,8 +162,10 @@ function testUpdateContribOrder() { * Tests that subthemes are notified about security updates for base themes. */ function testUpdateBaseThemeSecurityUpdate() { - // Only enable the subtheme, not the base theme. - theme_enable(array('update_test_subtheme')); + // @todo https://www.drupal.org/node/2338175 base themes have to be + // installed. + // Only install the subtheme, not the base theme. + \Drupal::service('theme_handler')->install(array('update_test_subtheme')); // Define the initial state for core and the subtheme. $system_info = array( @@ -197,6 +199,9 @@ function testUpdateBaseThemeSecurityUpdate() { /** * Tests that disabled themes are only shown when desired. + * + * @todo https://www.drupal.org/node/2338175 extensions can not be hidden and + * base themes have to be installed. */ function testUpdateShowDisabledThemes() { $update_settings = \Drupal::config('update.settings'); @@ -244,7 +249,8 @@ function testUpdateShowDisabledThemes() { foreach (array(TRUE, FALSE) as $check_disabled) { $update_settings->set('check.disabled_extensions', $check_disabled)->save(); $this->refreshUpdateStatus($xml_mapping); - // In neither case should we see the "Themes" heading for enabled themes. + // In neither case should we see the "Themes" heading for installed + // themes. $this->assertNoText(t('Themes')); if ($check_disabled) { $this->assertText(t('Disabled themes')); @@ -265,8 +271,8 @@ function testUpdateShowDisabledThemes() { function testUpdateHiddenBaseTheme() { module_load_include('compare.inc', 'update'); - // Enable the subtheme. - theme_enable(array('update_test_subtheme')); + // Install the subtheme. + \Drupal::service('theme_handler')->install(array('update_test_subtheme')); // Add a project and initial state for base theme and subtheme. $system_info = array( diff --git a/core/modules/update/update.module b/core/modules/update/update.module index 6529a48f555763e34b20c1b047fd6e40d24d40b1..4201e5d4145fcea0ca56bfc967ec395181957bb4 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -231,21 +231,21 @@ function update_cron() { } /** - * Implements hook_themes_enabled(). + * Implements hook_themes_installed(). * - * If themes are enabled, we invalidate the information of available updates. + * If themes are installed, we invalidate the information of available updates. */ -function update_themes_enabled($themes) { +function update_themes_installed($themes) { // Clear all update module data. update_storage_clear(); } /** - * Implements hook_themes_disabled(). + * Implements hook_themes_uninstalled(). * - * If themes are disabled, we invalidate the information of available updates. + * If themes are uninstalled, we invalidate the information of available updates. */ -function update_themes_disabled($themes) { +function update_themes_uninstalled($themes) { // Clear all update module data. update_storage_clear(); } diff --git a/core/modules/views/src/Tests/ViewsThemeIntegrationTest.php b/core/modules/views/src/Tests/ViewsThemeIntegrationTest.php index a73523ce327abdabfd71447b27510f35bee218f9..e368c84f230f86ad27e5d04889e49adc5229af3f 100644 --- a/core/modules/views/src/Tests/ViewsThemeIntegrationTest.php +++ b/core/modules/views/src/Tests/ViewsThemeIntegrationTest.php @@ -50,7 +50,7 @@ protected function setUp() { */ public function testThemedViewPage() { - \Drupal::service('theme_handler')->enable(array('test_basetheme', 'test_subtheme')); + \Drupal::service('theme_handler')->install(array('test_basetheme', 'test_subtheme')); // Make base theme default then test for hook invocations. \Drupal::config('system.theme') diff --git a/core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php b/core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php index b1c1c8be6f76c959399e5cc23ab49a0fb60d724c..a4bb8b122434b11b4a2ad81e8e8aa131a53aa259 100644 --- a/core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php @@ -32,9 +32,6 @@ public function testConfigIsEmpty() { $expected = array( 'module' => array(), 'theme' => array(), - 'disabled' => array( - 'theme' => array(), - ), ); $this->assertEquals($expected, $config); } diff --git a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php index 56bab8f4c324fe0cd252172cdd4f6309141b080d..3d89abe5031fdac7a035102fbb67a30e061cc54d 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php @@ -63,6 +63,13 @@ class ThemeHandlerTest extends UnitTestCase { */ protected $configInstaller; + /** + * The mocked config manager. + * + * @var \Drupal\Core\Config\ConfigManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $configManager; + /** * The extension discovery. * @@ -101,6 +108,7 @@ protected function setUp() { $this->state = new State(new KeyValueMemoryFactory()); $this->infoParser = $this->getMock('Drupal\Core\Extension\InfoParserInterface'); $this->configInstaller = $this->getMock('Drupal\Core\Config\ConfigInstallerInterface'); + $this->configManager = $this->getMock('Drupal\Core\Config\ConfigManagerInterface'); $this->routeBuilder = $this->getMockBuilder('Drupal\Core\Routing\RouteBuilder') ->disableOriginalConstructor() ->getMock(); @@ -111,7 +119,7 @@ protected function setUp() { ->disableOriginalConstructor() ->getMock(); $logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->themeHandler = new TestThemeHandler($this->configFactory, $this->moduleHandler, $this->state, $this->infoParser, $logger, $this->cssCollectionOptimizer, $this->configInstaller, $this->routeBuilder, $this->extensionDiscovery); + $this->themeHandler = new TestThemeHandler($this->configFactory, $this->moduleHandler, $this->state, $this->infoParser, $logger, $this->cssCollectionOptimizer, $this->configInstaller, $this->configManager, $this->routeBuilder, $this->extensionDiscovery); $cache_backend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface'); $this->getContainerWithCacheBins($cache_backend);