blob: f4c71851a251fbb28d65ce3ab394fff9f853f60e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<?php
namespace ipl\Web\Compat;
use Icinga\Application\Version;
use Icinga\Util\Csp;
use ipl\Web\Style;
/**
* Use this class to define inline style which is compatible
* with Icinga Web < 2.12 and with CSP support in >= 2.12
*/
class StyleWithNonce extends Style
{
public function getNonce(): ?string
{
if ($this->nonce === null) {
$this->nonce = version_compare(Version::VERSION, '2.12.0', '>=')
? Csp::getStyleNonce() ?? ''
: '';
}
return parent::getNonce();
}
}
|