‪TYPO3CMS  ‪main
Mutation.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 
25 class ‪Mutation implements \JsonSerializable
26 {
30  public readonly array ‪$sources;
31 
32  public function ‪__construct(
33  public readonly ‪MutationMode $mode,
34  public readonly ‪Directive $directive,
36  ) {
37  // @todo continue with source collecting internally?
38  if (‪$sources !== [] && $this->mode === ‪MutationMode::Remove) {
39  throw new \LogicException(
40  'Cannot remove and declare sources at the same time',
41  1677244893
42  );
43  }
44  $this->sources = ‪$sources;
45  }
46 
47  public function ‪jsonSerialize(): array
48  {
49  $service = GeneralUtility::makeInstance(ModelService::class);
50  return [
51  'mode' => $this->mode,
52  'directive' => $this->directive,
53  'sources' => $service->serializeSources(...$this->sources),
54  ];
55  }
56 }
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Directive
‪Directive
Definition: Directive.php:25
‪TYPO3\CMS\Core\Http\Remove
‪@ Remove
Definition: SetCookieBehavior.php:27
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Mutation\__construct
‪__construct(public readonly MutationMode $mode, public readonly Directive $directive, SourceInterface ... $sources,)
Definition: Mutation.php:32
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\SourceInterface
Definition: SourceInterface.php:27
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\MutationMode
‪MutationMode
Definition: MutationMode.php:24
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy
Definition: ConsumableNonce.php:18
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Mutation\$sources
‪readonly array $sources
Definition: Mutation.php:30
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Mutation\jsonSerialize
‪jsonSerialize()
Definition: Mutation.php:47
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Mutation
Definition: Mutation.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52