Loading core/lib/Drupal/Core/Extension/ThemeInstaller.php +2 −2 Original line number Diff line number Diff line Loading @@ -266,7 +266,7 @@ public function uninstall(array $theme_list) { $theme_config = $this->configFactory->getEditable('system.theme'); $list = $this->themeHandler->listInfo(); foreach ($theme_list as $key) { if (!isset($list[$key])) { if ($extension_config->get("theme.$key") === NULL) { throw new UnknownExtensionException("Unknown theme: $key."); } if ($key === $theme_config->get('default')) { Loading @@ -277,7 +277,7 @@ public function uninstall(array $theme_list) { } // Base themes cannot be uninstalled if sub themes are installed, and if // they are not uninstalled at the same time. if (!empty($list[$key]->sub_themes)) { if (isset($list[$key]) && !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 uninstalled, because theme $sub_key depends on it."); Loading core/lib/Drupal/Core/Extension/ThemeInstallerInterface.php +4 −3 Original line number Diff line number Diff line Loading @@ -41,12 +41,13 @@ public function install(array $theme_list, $install_dependencies = TRUE); * Uninstalling a theme removes all related configuration (like blocks) and * invokes the 'themes_uninstalled' hook. * * Themes are allowed to be uninstalled even when their code has been removed * from the filesystem, this is because themes do not allow uninstall hooks to * be defined. * * @param array $theme_list * The themes to uninstall. * * @throws \Drupal\Core\Extension\Exception\UnknownExtensionException * Thrown when trying to uninstall a theme that was not installed. * * @throws \InvalidArgumentException * Thrown when trying to uninstall the admin theme, the default theme or * a theme that another theme depends on. Loading core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php +6 −19 Original line number Diff line number Diff line Loading @@ -355,17 +355,8 @@ public function testUninstallNonExisting() { $themes = $this->themeHandler()->listInfo(); $this->assertEmpty(array_keys($themes)); try { $message = 'ThemeInstaller::uninstall() throws UnknownExtensionException upon uninstalling a non-existing theme.'; $this->expectException(UnknownExtensionException::class); $this->themeInstaller()->uninstall([$name]); $this->fail($message); } catch (\Exception $e) { $this->assertInstanceOf(UnknownExtensionException::class, $e); } $themes = $this->themeHandler()->listInfo(); $this->assertEmpty(array_keys($themes)); } /** Loading Loading @@ -397,14 +388,10 @@ public function testUninstall() { public function testUninstallNotInstalled() { $name = 'test_basetheme'; try { $message = 'ThemeInstaller::uninstall() throws UnknownExtensionException upon uninstalling a theme that is not installed.'; $themes = $this->themeHandler()->listInfo(); $this->assertEmpty(array_keys($themes)); $this->expectException(UnknownExtensionException::class); $this->themeInstaller()->uninstall([$name]); $this->fail($message); } catch (\Exception $e) { $this->assertInstanceOf(UnknownExtensionException::class, $e); } } /** Loading Loading
core/lib/Drupal/Core/Extension/ThemeInstaller.php +2 −2 Original line number Diff line number Diff line Loading @@ -266,7 +266,7 @@ public function uninstall(array $theme_list) { $theme_config = $this->configFactory->getEditable('system.theme'); $list = $this->themeHandler->listInfo(); foreach ($theme_list as $key) { if (!isset($list[$key])) { if ($extension_config->get("theme.$key") === NULL) { throw new UnknownExtensionException("Unknown theme: $key."); } if ($key === $theme_config->get('default')) { Loading @@ -277,7 +277,7 @@ public function uninstall(array $theme_list) { } // Base themes cannot be uninstalled if sub themes are installed, and if // they are not uninstalled at the same time. if (!empty($list[$key]->sub_themes)) { if (isset($list[$key]) && !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 uninstalled, because theme $sub_key depends on it."); Loading
core/lib/Drupal/Core/Extension/ThemeInstallerInterface.php +4 −3 Original line number Diff line number Diff line Loading @@ -41,12 +41,13 @@ public function install(array $theme_list, $install_dependencies = TRUE); * Uninstalling a theme removes all related configuration (like blocks) and * invokes the 'themes_uninstalled' hook. * * Themes are allowed to be uninstalled even when their code has been removed * from the filesystem, this is because themes do not allow uninstall hooks to * be defined. * * @param array $theme_list * The themes to uninstall. * * @throws \Drupal\Core\Extension\Exception\UnknownExtensionException * Thrown when trying to uninstall a theme that was not installed. * * @throws \InvalidArgumentException * Thrown when trying to uninstall the admin theme, the default theme or * a theme that another theme depends on. Loading
core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php +6 −19 Original line number Diff line number Diff line Loading @@ -355,17 +355,8 @@ public function testUninstallNonExisting() { $themes = $this->themeHandler()->listInfo(); $this->assertEmpty(array_keys($themes)); try { $message = 'ThemeInstaller::uninstall() throws UnknownExtensionException upon uninstalling a non-existing theme.'; $this->expectException(UnknownExtensionException::class); $this->themeInstaller()->uninstall([$name]); $this->fail($message); } catch (\Exception $e) { $this->assertInstanceOf(UnknownExtensionException::class, $e); } $themes = $this->themeHandler()->listInfo(); $this->assertEmpty(array_keys($themes)); } /** Loading Loading @@ -397,14 +388,10 @@ public function testUninstall() { public function testUninstallNotInstalled() { $name = 'test_basetheme'; try { $message = 'ThemeInstaller::uninstall() throws UnknownExtensionException upon uninstalling a theme that is not installed.'; $themes = $this->themeHandler()->listInfo(); $this->assertEmpty(array_keys($themes)); $this->expectException(UnknownExtensionException::class); $this->themeInstaller()->uninstall([$name]); $this->fail($message); } catch (\Exception $e) { $this->assertInstanceOf(UnknownExtensionException::class, $e); } } /** Loading