| Conditions | 6 |
| Paths | 5 |
| Total Lines | 21 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | 2 | public function onAfterInit() |
|
| 12 | { |
||
| 13 | 2 | $response = $this->owner->getResponse(); |
|
| 14 | |||
| 15 | 2 | $headersToSend = (array) Config::inst()->get('Guttmann\SilverStripe\SecurityHeaderControllerExtension', 'headers'); |
|
| 16 | 2 | $xHeaderMap = (array) Config::inst()->get('Guttmann\SilverStripe\SecurityHeaderControllerExtension', 'x_headers_map'); |
|
| 17 | |||
| 18 | 2 | foreach ($headersToSend as $header => $value) { |
|
| 19 | 2 | if ($header === 'Content-Security-Policy' && !$this->browserHasWorkingCSPImplementation()) { |
|
| 20 | 1 | continue; |
|
| 21 | } |
||
| 22 | |||
| 23 | 2 | $response->addHeader($header, $value); |
|
| 24 | |||
| 25 | 2 | if (isset($xHeaderMap[$header])) { |
|
| 26 | 2 | foreach ($xHeaderMap[$header] as $xHeader) { |
|
| 27 | 2 | $response->addHeader($xHeader, $value); |
|
| 28 | 2 | } |
|
| 29 | 2 | } |
|
| 30 | 2 | } |
|
| 31 | 2 | } |
|
| 32 | |||
| 60 |