function lightning_api_install in Lightning API 8.3
Same name and namespace in other branches
- 8.4 lightning_api.install \lightning_api_install()
- 8 lightning_api.install \lightning_api_install()
- 8.2 lightning_api.install \lightning_api_install()
Implements hook_install().
File
- ./
lightning_api.install, line 15 - Install, update, and uninstall functions for the Lightning API module.
Code
function lightning_api_install() {
$module_handler = \Drupal::moduleHandler();
// If the openapi_ui_redoc and jsonapi modules are installed, give the API
// documentation a nice path alias.
if ($module_handler
->moduleExists('openapi_ui_redoc') && $module_handler
->moduleExists('jsonapi')) {
/** @var \Drupal\Core\Path\AliasStorageInterface $alias_storage */
$alias_storage = \Drupal::service('path.alias_storage');
$path = $alias_storage
->lookupPathSource('/api-docs', LanguageInterface::LANGCODE_NOT_SPECIFIED);
if (empty($path)) {
$route_parameters = [
'openapi_ui' => 'redoc',
'openapi_generator' => 'jsonapi',
];
$alias_storage
->save(Url::fromRoute('openapi.documentation', $route_parameters)
->toString(), '/api-docs');
}
}
// Disable the content view's 'Include destination' switch.
if (!\Drupal::isConfigSyncing()) {
lightning_api_update_8301();
}
}