You are here

public static function Csp::sortDirectives in Content-Security-Policy 8

Sort an array of directives.

Parameters

array $directives: An array of directives.

Return value

array The sorted directives.

1 call to Csp::sortDirectives()
Csp::getHeaderValue in src/Csp.php
Get the header value.

File

src/Csp.php, line 538

Class

Csp
A CSP Header.

Namespace

Drupal\csp

Code

public static function sortDirectives(array $directives) {
  $order = array_flip(array_keys(self::DIRECTIVES));
  uksort($directives, function ($a, $b) use ($order) {
    return $order[$a] <=> $order[$b];
  });
  return $directives;
}