Skip to content

Commit

Permalink
Fix Issue apigee#669 : Add Check for Module and Theme exists before u…
Browse files Browse the repository at this point in the history
…ninstall. (apigee#670)

* Fix Issue apigee#669 : Add Check for Module and Theme exists before uninstall.

* Update apigee_devportal_kickstart.install

* Update apigee_devportal_kickstart.install

Co-authored-by: Divyajose <[email protected]>

* Update apigee_devportal_kickstart.install

Co-authored-by: Divyajose <[email protected]>

---------

Co-authored-by: Divyajose <[email protected]>
  • Loading branch information
bhanu951 and divya-intelli authored Nov 24, 2023
1 parent 344d920 commit 6340d4a
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions apigee_devportal_kickstart.install
Original file line number Diff line number Diff line change
Expand Up @@ -659,17 +659,33 @@ function apigee_devportal_kickstart_update_9001() {
* Installing ckeditor5, claro, olivero.
*/
function apigee_devportal_kickstart_update_9002() {
$module_handler = \Drupal::service('module_handler');
$theme_handler = \Drupal::service('theme_handler');
$module_installer = \Drupal::service('module_installer');
$theme_installer = \Drupal::service('theme_installer');

// Install admin theme and frontend theme.
\Drupal::service('theme_installer')->install(['claro']);
\Drupal::service('theme_installer')->install(['olivero']);
$theme_installer->install(['claro']);
$theme_installer->install(['olivero']);
// Set the admin theme as claro.Theme seven is deprecated and removed from Drupal 10.
$config = \Drupal::service('config.factory')->getEditable('system.theme');
$config->set('admin', 'claro')->save();

$deprecated_themes = ['seven', 'bartik'];
$deprecated_modules = ['hal', 'color'];
// Uninstall deprecated theme and module.
\Drupal::service('theme_installer')->uninstall(['seven', 'bartik']);
\Drupal::service('module_installer')->uninstall(['hal', 'color']);
foreach($deprecated_modules as $deprecated_module) {
if($module_handler->moduleExists($deprecated_module)) {
$module_installer->uninstall([$deprecated_module]);
}
}
foreach($deprecated_themes as $deprecated_theme) {
if($theme_handler->themeExists($deprecated_theme)) {
$theme_installer->uninstall([$deprecated_theme]);
}
}
// Install ckeditor5 as it is recommened module.
\Drupal::service('module_installer')->install(['ckeditor5']);
$module_installer->install(['ckeditor5']);

// id with node_type is deprecated in Drupal 9 and removed in Drupal 10.
$configToImport = [
Expand Down Expand Up @@ -703,4 +719,4 @@ function apigee_devportal_kickstart_update_9002() {

// Clear all caches.
drupal_flush_all_caches();
}
}

0 comments on commit 6340d4a

Please sign in to comment.