Issue #3265362 by quietone, dww, murilohp: Do not display obsolete themes at admin/appearance
(cherry picked from commit d7a82b5b1a
)
merge-requests/2535/head
parent
1d7fd63519
commit
f200a37dd2
|
@ -209,4 +209,17 @@ class Extension {
|
|||
&& $this->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::EXPERIMENTAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an extension is marked as obsolete.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if an extension is marked as obsolete, FALSE otherwise.
|
||||
*/
|
||||
public function isObsolete(): bool {
|
||||
// This function checks for 'lifecycle: obsolete' to determine if an
|
||||
// extension is marked as obsolete.
|
||||
return (isset($this->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER])
|
||||
&& $this->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::OBSOLETE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ class SystemController extends ControllerBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a theme listing.
|
||||
* Returns a theme listing which excludes obsolete themes.
|
||||
*
|
||||
* @return string
|
||||
* An HTML string of the theme listing page.
|
||||
|
@ -206,6 +206,11 @@ class SystemController extends ControllerBase {
|
|||
$config = $this->config('system.theme');
|
||||
// Get all available themes.
|
||||
$themes = $this->themeHandler->rebuildThemeData();
|
||||
|
||||
// Remove obsolete themes.
|
||||
$themes = array_filter($themes, function ($theme) {
|
||||
return !$theme->isObsolete();
|
||||
});
|
||||
uasort($themes, [ThemeExtensionList::class, 'sortByName']);
|
||||
|
||||
$theme_default = $config->get('default');
|
||||
|
|
|
@ -320,6 +320,10 @@ class ThemeTest extends BrowserTestBase {
|
|||
$this->drupalGet('admin/appearance');
|
||||
$this->submitForm($edit, 'Save configuration');
|
||||
|
||||
// Check that obsolete themes are not displayed.
|
||||
$this->drupalGet('admin/appearance');
|
||||
$this->assertSession()->pageTextNotContains('Obsolete test theme');
|
||||
|
||||
// Check that the administration theme is used on an administration page.
|
||||
$this->drupalGet('admin/config');
|
||||
$this->assertSession()->responseContains('core/themes/seven');
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
name: 'Obsolete theme test'
|
||||
type: theme
|
||||
description: 'Obsolete test theme.'
|
||||
version: VERSION
|
||||
lifecycle: obsolete
|
||||
lifecycle_link: 'https://example.com/obsolete'
|
||||
base theme: false
|
Loading…
Reference in New Issue