diff --git a/helfi_api_base.install b/helfi_api_base.install index 43b445b8..db934143 100644 --- a/helfi_api_base.install +++ b/helfi_api_base.install @@ -45,9 +45,15 @@ function helfi_api_base_install() : void { ]); } + // Install the debug rest config. + helfi_api_base_install_debug_rest_config(); + + // Create debug_api role. if (!$role = Role::load('debug_api')) { $role = Role::create(['label' => 'Debug API', 'id' => 'debug_api']); } + + // Grant the restful get helfi_debug_data permission. $role->grantPermission('restful get helfi_debug_data') ->save(); } @@ -55,6 +61,21 @@ function helfi_api_base_install() : void { } } +/** + * Install the debug rest config. + */ +function helfi_api_base_install_debug_rest_config() : void { + /** @var \Drupal\Core\Extension\ExtensionPathResolver $extensionPathResolver */ + $extensionPathResolver = Drupal::service('extension.path.resolver'); + $config_path = $extensionPathResolver->getPath('module', 'helfi_api_base') . '/config/optional'; + $source = new FileStorage($config_path); + $config_storage = Drupal::service('config.storage'); + + // Install rest resource config. + $config_name = 'rest.resource.helfi_debug_data'; + $config_storage->write($config_name, $source->read($config_name)); +} + /** * Enable 'helfi_link_converter' filter format. */ @@ -69,15 +90,7 @@ function helfi_api_base_update_9002() : void { if (!Drupal::moduleHandler()->moduleExists('rest')) { return; } - /** @var \Drupal\Core\Extension\ExtensionPathResolver $extensionPathResolver */ - $extensionPathResolver = Drupal::service('extension.path.resolver'); - $config_path = $extensionPathResolver->getPath('module', 'helfi_api_base') . '/config/optional'; - $source = new FileStorage($config_path); - $config_storage = Drupal::service('config.storage'); - - // Install rest resource config. - $config_name = 'rest.resource.helfi_debug_data'; - $config_storage->write($config_name, $source->read($config_name)); + helfi_api_base_install_debug_rest_config(); } /**