You are here

public function SiteLog::alterPolicy in Content-Security-Policy 8

Alter the provided policy according to the plugin settings.

Parameters

\Drupal\csp\Csp $policy: The policy to alter.

Overrides ReportingHandlerBase::alterPolicy

File

src/Plugin/CspReportingHandler/SiteLog.php, line 23

Class

SiteLog
Csp Reporting Handler to use Drupal log.

Namespace

Drupal\csp\Plugin\CspReportingHandler

Code

public function alterPolicy(Csp $policy) {
  $reportUri = Url::fromRoute('csp.reporturi', [
    'type' => $this->configuration['type'] == 'enforce' ? 'enforce' : 'reportOnly',
  ], [
    'absolute' => TRUE,
  ]);
  $policy
    ->setDirective('report-uri', $reportUri
    ->toString());
}