You are here

function csp_update_8101 in Content-Security-Policy 8

Update configuration for Reporting Plugins.

File

./csp.install, line 138
Installation hooks for csp.module.

Code

function csp_update_8101() {
  $config = \Drupal::configFactory()
    ->getEditable('csp.settings');
  $pluginMap = [
    '' => 'none',
    'report-uri-com' => 'report-uri-com',
    'csp-module' => 'sitelog',
    'uri' => 'uri',
  ];
  $reportConfig = $config
    ->get('report');
  $reportConfig['plugin'] = $pluginMap[$reportConfig['handler']];
  unset($reportConfig['handler']);
  $config
    ->set('report', $reportConfig)
    ->save();
}