Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
225
Merge Requests
225
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
2a0254f9
Commit
2a0254f9
authored
Sep 19, 2014
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2232605
by alexpott, dawehner, martin107, Cottser, sun: Fixed Themes cannot be uninstalled.
parent
f27fd1f5
Changes
72
Hide whitespace changes
Inline
Side-by-side
Showing
72 changed files
with
486 additions
and
497 deletions
+486
-497
core/config/install/core.extension.yml
core/config/install/core.extension.yml
+0
-2
core/config/schema/core.extension.schema.yml
core/config/schema/core.extension.schema.yml
+1
-11
core/core.services.yml
core/core.services.yml
+1
-1
core/includes/install.core.inc
core/includes/install.core.inc
+4
-4
core/includes/module.inc
core/includes/module.inc
+2
-2
core/includes/theme.inc
core/includes/theme.inc
+1
-37
core/includes/update.inc
core/includes/update.inc
+0
-3
core/lib/Drupal/Core/Config/ConfigImporter.php
core/lib/Drupal/Core/Config/ConfigImporter.php
+28
-46
core/lib/Drupal/Core/Extension/ThemeHandler.php
core/lib/Drupal/Core/Extension/ThemeHandler.php
+64
-52
core/lib/Drupal/Core/Extension/ThemeHandlerInterface.php
core/lib/Drupal/Core/Extension/ThemeHandlerInterface.php
+32
-17
core/lib/Drupal/Core/Theme/ThemeAccessCheck.php
core/lib/Drupal/Core/Theme/ThemeAccessCheck.php
+2
-2
core/lib/Drupal/Core/Theme/ThemeInitialization.php
core/lib/Drupal/Core/Theme/ThemeInitialization.php
+7
-7
core/lib/Drupal/Core/Updater/Theme.php
core/lib/Drupal/Core/Updater/Theme.php
+1
-1
core/lib/Drupal/Core/Utility/ProjectInfo.php
core/lib/Drupal/Core/Utility/ProjectInfo.php
+18
-13
core/modules/block/block.module
core/modules/block/block.module
+6
-6
core/modules/block/src/Tests/BlockAdminThemeTest.php
core/modules/block/src/Tests/BlockAdminThemeTest.php
+4
-3
core/modules/block/src/Tests/BlockHiddenRegionTest.php
core/modules/block/src/Tests/BlockHiddenRegionTest.php
+5
-5
core/modules/block/src/Tests/BlockTest.php
core/modules/block/src/Tests/BlockTest.php
+23
-3
core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php
core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php
+2
-2
core/modules/block/src/Tests/NonDefaultBlockAdminTest.php
core/modules/block/src/Tests/NonDefaultBlockAdminTest.php
+1
-1
core/modules/block_content/src/Tests/BlockContentTypeTest.php
.../modules/block_content/src/Tests/BlockContentTypeTest.php
+3
-3
core/modules/breakpoint/breakpoint.module
core/modules/breakpoint/breakpoint.module
+4
-4
core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php
.../modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php
+1
-1
core/modules/color/src/Tests/ColorConfigSchemaTest.php
core/modules/color/src/Tests/ColorConfigSchemaTest.php
+1
-1
core/modules/color/src/Tests/ColorTest.php
core/modules/color/src/Tests/ColorTest.php
+1
-1
core/modules/comment/src/Tests/CommentLinksTest.php
core/modules/comment/src/Tests/CommentLinksTest.php
+1
-1
core/modules/config/src/Tests/ConfigImportUITest.php
core/modules/config/src/Tests/ConfigImportUITest.php
+2
-3
core/modules/config_translation/config_translation.module
core/modules/config_translation/config_translation.module
+4
-4
core/modules/config_translation/src/ConfigMapperManager.php
core/modules/config_translation/src/ConfigMapperManager.php
+3
-3
core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php
...ig_translation/src/Tests/ConfigTranslationUiThemeTest.php
+2
-2
core/modules/locale/locale.module
core/modules/locale/locale.module
+4
-7
core/modules/menu_link_content/src/Tests/MenuLinkContentUITest.php
...les/menu_link_content/src/Tests/MenuLinkContentUITest.php
+1
-1
core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php
.../modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php
+2
-2
core/modules/node/src/Tests/NodeTranslationUITest.php
core/modules/node/src/Tests/NodeTranslationUITest.php
+1
-1
core/modules/responsive_image/src/ResponsiveImageMappingForm.php
...dules/responsive_image/src/ResponsiveImageMappingForm.php
+2
-2
core/modules/shortcut/src/Tests/ShortcutLinksTest.php
core/modules/shortcut/src/Tests/ShortcutLinksTest.php
+3
-3
core/modules/system/css/system.admin.css
core/modules/system/css/system.admin.css
+20
-20
core/modules/system/src/Controller/SystemController.php
core/modules/system/src/Controller/SystemController.php
+15
-15
core/modules/system/src/Controller/ThemeController.php
core/modules/system/src/Controller/ThemeController.php
+12
-12
core/modules/system/src/Form/ThemeSettingsForm.php
core/modules/system/src/Form/ThemeSettingsForm.php
+1
-1
core/modules/system/src/Tests/Ajax/FrameworkTest.php
core/modules/system/src/Tests/Ajax/FrameworkTest.php
+1
-1
core/modules/system/src/Tests/Batch/PageTest.php
core/modules/system/src/Tests/Batch/PageTest.php
+1
-1
core/modules/system/src/Tests/Common/AlterTest.php
core/modules/system/src/Tests/Common/AlterTest.php
+1
-1
core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php
.../system/src/Tests/Condition/CurrentThemeConditionTest.php
+1
-1
core/modules/system/src/Tests/Extension/ThemeHandlerTest.php
core/modules/system/src/Tests/Extension/ThemeHandlerTest.php
+84
-112
core/modules/system/src/Tests/Menu/MenuRouterTest.php
core/modules/system/src/Tests/Menu/MenuRouterTest.php
+8
-8
core/modules/system/src/Tests/System/ThemeTest.php
core/modules/system/src/Tests/System/ThemeTest.php
+6
-6
core/modules/system/src/Tests/Theme/EnginePhpTemplateTest.php
.../modules/system/src/Tests/Theme/EnginePhpTemplateTest.php
+1
-1
core/modules/system/src/Tests/Theme/EngineTwigTest.php
core/modules/system/src/Tests/Theme/EngineTwigTest.php
+1
-1
core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php
...dules/system/src/Tests/Theme/EntityFilteringThemeTest.php
+2
-2
core/modules/system/src/Tests/Theme/ThemeInfoTest.php
core/modules/system/src/Tests/Theme/ThemeInfoTest.php
+2
-2
core/modules/system/src/Tests/Theme/ThemeSettingsTest.php
core/modules/system/src/Tests/Theme/ThemeSettingsTest.php
+2
-2
core/modules/system/src/Tests/Theme/ThemeSuggestionsAlterTest.php
...ules/system/src/Tests/Theme/ThemeSuggestionsAlterTest.php
+6
-6
core/modules/system/src/Tests/Theme/ThemeTest.php
core/modules/system/src/Tests/Theme/ThemeTest.php
+6
-5
core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php
core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php
+1
-1
core/modules/system/src/Tests/Theme/TwigExtensionTest.php
core/modules/system/src/Tests/Theme/TwigExtensionTest.php
+1
-1
core/modules/system/src/Tests/Theme/TwigNamespaceTest.php
core/modules/system/src/Tests/Theme/TwigNamespaceTest.php
+1
-1
core/modules/system/src/Tests/Theme/TwigSettingsTest.php
core/modules/system/src/Tests/Theme/TwigSettingsTest.php
+1
-1
core/modules/system/src/Tests/Theme/TwigTransTest.php
core/modules/system/src/Tests/Theme/TwigTransTest.php
+1
-1
core/modules/system/system.api.php
core/modules/system/system.api.php
+23
-0
core/modules/system/system.module
core/modules/system/system.module
+2
-2
core/modules/system/system.routing.yml
core/modules/system/system.routing.yml
+6
-6
core/modules/system/templates/system-themes-page.html.twig
core/modules/system/templates/system-themes-page.html.twig
+1
-1
core/modules/system/tests/modules/menu_test/src/Theme/TestThemeNegotiator.php
...tests/modules/menu_test/src/Theme/TestThemeNegotiator.php
+1
-1
core/modules/system/theme.api.php
core/modules/system/theme.api.php
+12
-10
core/modules/taxonomy/src/Tests/ThemeTest.php
core/modules/taxonomy/src/Tests/ThemeTest.php
+1
-1
core/modules/tour/src/Tests/TourTestBasic.php
core/modules/tour/src/Tests/TourTestBasic.php
+1
-1
core/modules/update/src/Tests/UpdateContribTest.php
core/modules/update/src/Tests/UpdateContribTest.php
+11
-5
core/modules/update/update.module
core/modules/update/update.module
+6
-6
core/modules/views/src/Tests/ViewsThemeIntegrationTest.php
core/modules/views/src/Tests/ViewsThemeIntegrationTest.php
+1
-1
core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php
core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php
+0
-3
core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php
core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php
+9
-1
No files found.
core/config/install/core.extension.yml
View file @
2a0254f9
module
:
{}
theme
:
{}
disabled
:
theme
:
{}
core/config/schema/core.extension.schema.yml
View file @
2a0254f9
...
...
@@ -10,17 +10,7 @@ core.extension:
label
:
'
Weight'
theme
:
type
:
sequence
label
:
'
Enab
led
themes'
label
:
'
Instal
led
themes'
sequence
:
-
type
:
integer
label
:
'
Weight'
disabled
:
type
:
mapping
label
:
'
Disabled
extensions'
mapping
:
theme
:
type
:
sequence
label
:
'
Disabled
themes'
sequence
:
-
type
:
integer
label
:
'
Weight'
core/core.services.yml
View file @
2a0254f9
...
...
@@ -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'
]
...
...
core/includes/install.core.inc
View file @
2a0254f9
...
...
@@ -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
enable
s 1-3 themes only (default
* because an installation profile typically
install
s 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
);
...
...
core/includes/module.inc
View file @
2a0254f9
...
...
@@ -9,11 +9,11 @@
use
Drupal\Core\Extension\ExtensionDiscovery
;
/**
* Builds a list of
enab
led themes.
* Builds a list of
instal
led themes.
*
* @param $type
* The type of list to return:
* - theme: All
enab
led themes.
* - theme: All
instal
led themes.
*
* @return
* An associative array of themes, keyed by name.
...
...
core/includes/theme.inc
View file @
2a0254f9
...
...
@@ -77,7 +77,7 @@
* Either the name of a theme or a full theme object.
*
* @return bool
* Boolean TRUE if the theme is
enab
led or is the site administration theme;
* Boolean TRUE if the theme is
instal
led 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
* @{
...
...
core/includes/update.inc
View file @
2a0254f9
...
...
@@ -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
;
}
}
...
...
core/lib/Drupal/Core/Config/ConfigImporter.php
View file @
2a0254f9
...
...
@@ -124,7 +124,7 @@ class ConfigImporter {
protected
$themeHandler
;
/**
* Flag set to import system.theme during processing theme
enable and disable
s.
* Flag set to import system.theme during processing theme
install and uninstall
s.
*
* @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
disable
s possible remove default or admin themes therefore we
// need to import this before doing any. If there are no
disable
s and
// the default or admin theme is chang
e
this will be picked up whilst
// Theme
uninstall
s possible remove default or admin themes therefore we
// need to import this before doing any. If there are no
uninstall
s and
// the default or admin theme is chang
ing
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
;
...
...
core/lib/Drupal/Core/Extension/ThemeHandler.php
View file @
2a0254f9
...
...
@@ -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 them
es.
* Default theme handler using the config system
to store installation status
es.
*/
class
ThemeHandler
implements
ThemeHandlerInterface
{
...
...
@@ -46,14 +47,14 @@ class ThemeHandler implements ThemeHandlerInterface {
protected
$list
;
/**
* The config factory to get the
enab
led themes.
* The config factory to get the
instal
led themes.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected
$configFactory
;
/**
* The module handler to fire themes_
enabled/themes_disab
led hooks.
* The module handler to fire themes_
installed/themes_uninstal
led 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
enab
led.
* The route builder to rebuild the routes if a theme is
instal
led.
*
* @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
enab
led themes.
* The config factory to get the
instal
led themes.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to fire themes_
enabled/themes_disab
led hooks.
* The module handler to fire themes_
installed/themes_uninstal
led 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
enab
led."
);
throw
new
\
InvalidArgumentException
(
"
$name
theme is not
instal
led."
);
}
$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
enab
led currently.
// Only process themes that are not
instal
led currently.
$installed_themes
=
$extension_config
->
get
(
'theme'
)
?:
array
();
if
(
!
$theme_list
=
array_diff_key
(
$theme_list
,
$installed_themes
))
{
// Nothing to do. All themes already
enab
led.
// Nothing to do. All themes already
instal
led.
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_
enab
led
=
array
();
$themes_
instal
led
=
array
();
foreach
(
$theme_list
as
$key
)
{
// Only process themes that are not already
enab
led.
$
enab
led
=
$extension_config
->
get
(
"theme.
$key
"
)
!==
NULL
;
if
(
$
enab
led
)
{
// Only process themes that are not already
instal
led.
$
instal
led
=
$extension_config
->
get
(
"theme.
$key
"
)
!==
NULL
;
if
(
$
instal
led
)
{
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_
enab
led
[]
=
$key
;
$themes_
instal
led
[]
=
$key
;
// Record the fact that it was
enab
led.
$this
->
logger
->
info
(
'%theme theme
enab
led.'
,
array
(
'%theme'
=>
$key
));
// Record the fact that it was
instal
led.
$this
->
logger
->
info
(
'%theme theme
instal
led.'
,
array
(
'%theme'
=>
$key
));
}
$this
->
cssCollectionOptimizer
->
deleteAll
();
$this
->
resetSystem
();
// Invoke hook_themes_
enabled() after the themes have been enab
led.
$this
->
moduleHandler
->
invokeAll
(
'themes_
enabled'
,
array
(
$themes_enab
led
));
// Invoke hook_themes_
installed() after the themes have been instal
led.
$this
->
moduleHandler
->
invokeAll
(
'themes_
installed'
,
array
(
$themes_instal
led
));
return
!
empty
(
$themes_
enab
led
);
return
!
empty
(
$themes_
instal
led
);
}
/**
* {@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
disab
led."
);
throw
new
\
InvalidArgumentException
(
"The current default theme
$key
cannot be
uninstal
led."
);
}
if
(
$key
===
$theme_config
->
get
(
'admin'
))
{
throw
new
\
InvalidArgumentException
(
"The current admin theme
$key
cannot be
disab
led."
);
throw
new
\
InvalidArgumentException
(
"The current admin theme
$key
cannot be
uninstal
led."
);
}
// 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
disab
led, because theme
$sub_key
depends on it."
);
throw
new
\
InvalidArgumentException
(
"The base theme
$key
cannot be
uninstal
led, 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'
);
$
enab
led
=
$extension_config
->
get
(
'theme'
);
$
instal
led
=
$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
(
$
enab
led
[
$name
]))
{
if
(
isset
(
$
instal
led
[
$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'
);
$
enab
led
=
$extension_config
->
get
(
'theme'
)
?:
array
();
$
instal
led
=
$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
(
$
enab
led
[
$key
]);
$theme
->
status
=
(
int
)
isset
(
$
instal
led
[
$key
]);
$theme
->
info
=
$this
->
infoParser
->
parse
(
$theme
->
getPathname
())
+
$defaults
;
...
...
core/lib/Drupal/Core/Extension/ThemeHandlerInterface.php
View file @
2a0254f9
...
...
@@ -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
{
/**
*
Enable
s a given list of themes.
*
Install
s 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