function at_theme_generator_install in AT Tools 8.2
Same name and namespace in other branches
- 8.3 at_theme_generator/at_theme_generator.install \at_theme_generator_install()
- 8 at_theme_generator/at_theme_generator.install \at_theme_generator_install()
Implements hook_install().
File
- at_theme_generator/
at_theme_generator.install, line 13 - AT Theme Generator install file.
Code
function at_theme_generator_install() {
$list_info = \Drupal::service('theme_handler')
->listInfo();
$theme = 'at_generator';
// Check if the old at_generator is installed.
if (array_key_exists($theme, $list_info)) {
// Check if the old generator theme is default, if so replace with Bartik.
// Users sometimes made the mistake of setting the old generator theme as
// default which totally borks their site, we use this module install to
// to try and fix that issue for them.
if ($theme == \Drupal::service('theme_handler')
->getDefault()) {
\Drupal::service('theme_handler')
->setDefault('bartik');
drupal_set_message(t('Bartik set as default theme.'), 'status');
}
// Now uninstall it.
\Drupal::service('theme_installer')
->uninstall([
$theme,
]);
}
// Now remove the old generator theme.
$gen_path = drupal_get_path('theme', $theme);
if (!empty($gen_path)) {
$directoryOperations = new DirectoryOperations();
$directoryOperations
->directoryRemove($gen_path);
drupal_set_message(t('Old at_generator theme has been removed, please use the new Theme Generator tab in Appearance settings.'), 'status');
}
}