function lightning_api_update_8300 in Lightning API 8.4
Same name and namespace in other branches
- 8.2 lightning_api.install \lightning_api_update_8300()
- 8.3 lightning_api.install \lightning_api_update_8300()
Replaces openapi_redoc and openapi_swagger_ui with openapi_ui_* equivalents.
This is needed because the corresponding openapi update hook only installs them if the old versions are enabled.
See also
openapi_update_8100
File
- ./
lightning_api.install, line 74 - Contains installation and update routines for Lightning API.
Code
function lightning_api_update_8300() {
/** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
$module_installer = \Drupal::service('module_installer');
$uninstalled = $module_installer
->uninstall([
'openapi_redoc',
'openapi_swagger_ui',
]);
// If the uninstall failed -- for example, the openapi_redoc and
// openapi_swagger_ui modules were physically unavailable, as they would be if
// they were brought in by Composer back when they were all part of the
// openapi project before beta2 -- we need to forcibly remove them from the
// core.extension config so that they are actually uninstalled.
if (!$uninstalled) {
\Drupal::configFactory()
->getEditable('core.extension')
->clear('module.openapi_redoc')
->clear('module.openapi_swagger_ui')
->save();
Drupal::keyValue('system.schema')
->deleteMultiple([
'openapi_redoc',
'openapi_swagger_ui',
]);
}
$module_installer
->install([
'openapi_ui_swagger',
'openapi_ui_redoc',
]);
}