From 5329172a1a806d33fb36e3b5876945fcd8c8e75c Mon Sep 17 00:00:00 2001 From: Alena Stanul Date: Mon, 6 Feb 2023 06:49:34 +0000 Subject: [PATCH] [#69] Class 'Drupal\bootstrap\Bootstrap' not found error --- src/Service/SwaggerUiLibraryDiscovery.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Service/SwaggerUiLibraryDiscovery.php b/src/Service/SwaggerUiLibraryDiscovery.php index 3dcc30a3..55055ade 100644 --- a/src/Service/SwaggerUiLibraryDiscovery.php +++ b/src/Service/SwaggerUiLibraryDiscovery.php @@ -108,7 +108,16 @@ public function libraryDirectory(): string { $library_dir = 'libraries/swagger-ui'; // Allow the default theme to alter the default library directory. $default_theme = $this->themeInitialization->getActiveThemeByName($this->themeHandler->getDefault()); - $this->themeInitialization->loadActiveTheme($default_theme); + // @todo Remove \Throwable cathing when registration the namespaces + // of installed themes will be implemented. + // https://www.drupal.org/project/drupal/issues/2941757 + try { + $this->themeInitialization->loadActiveTheme($default_theme); + } + catch (\Throwable $error) { + $this->themeHandler->listInfo(); + $this->themeInitialization->loadActiveTheme($default_theme); + } // The hook is only invoked for the default theme (and its base themes). $this->themeManager->alterForTheme($default_theme, 'swagger_ui_library_directory', $library_dir); // Make sure that the directory path is relative (to DRUPAL ROOT).