Skip to content

Commit d046c37

Browse files
Merge pull request #19 from move-elevator/feature/asset-css-csp-option
2 parents 7f89f88 + 5ecae80 commit d046c37

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Classes/ViewHelpers/Asset/CssViewHelper.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public function initializeArguments(): void
5353
{
5454
parent::initializeArguments();
5555
$this->registerArgument('disabled', 'bool', 'Define whether or not the described stylesheet should be loaded and applied to the document.');
56-
$this->registerArgument('useNonce', 'bool', 'Whether to use the global nonce value', false, false);
56+
$this->registerArgument('useNonce', 'bool', 'Whether to use the global nonce value. @deprecated use "csp" instead, will be removed in 3.0.0.', false, null);
57+
$this->registerArgument('csp', 'bool', 'Whether to collect a CSP hash value for this asset', false, null);
5758
$this->registerArgument('identifier', 'string', 'Use this identifier within templates to only inject your CSS once, even though it is added multiple times.', true);
5859
$this->registerArgument('priority', 'boolean', 'Define whether the CSS should be included before other CSS. CSS will always be output in the <head> tag.', false, false);
5960
$this->registerArgument('inline', 'bool', 'Define whether or not the referenced file should be loaded as inline styles (Only to be used if \'href\' is set).', false, false);
@@ -73,9 +74,15 @@ public function render(): string
7374

7475
$file = $attributes['href'] ?? null;
7576
unset($attributes['href']);
77+
78+
$useCsp = $this->arguments['csp'];
79+
if ($this->arguments['useNonce'] !== null) {
80+
$useCsp = (bool)$this->arguments['useNonce'];
81+
}
82+
7683
$options = [
7784
'priority' => $this->arguments['priority'],
78-
'useNonce' => $this->arguments['useNonce'],
85+
'csp' => $useCsp,
7986
'noscript' => (bool)($this->arguments['noscript'] ?? false),
8087
];
8188

0 commit comments

Comments
 (0)