You are here

private function CspSettingsForm::getKeywordOptions in Content-Security-Policy 8

Get the valid keyword options for a directive.

Parameters

string $directive: The directive to get keywords for.

Return value

array An array of keywords.

1 call to CspSettingsForm::getKeywordOptions()
CspSettingsForm::buildForm in src/Form/CspSettingsForm.php
Form constructor.

File

src/Form/CspSettingsForm.php, line 140

Class

CspSettingsForm
Form for editing Content Security Policy module settings.

Namespace

Drupal\csp\Form

Code

private function getKeywordOptions($directive) {
  $allKeywords = [
    'unsafe-inline',
    'unsafe-eval',
    'unsafe-hashes',
    'unsafe-allow-redirects',
    'strict-dynamic',
    'report-sample',
  ];
  return array_filter($allKeywords, function ($keyword) use ($directive) {
    return !array_key_exists($keyword, self::$keywordDirectiveMap) || in_array($directive, self::$keywordDirectiveMap[$keyword]);
  });
}