‪TYPO3CMS  9.5
EnhancerDeclaration.php
Go to the documentation of this file.
1 <?php
2 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 {
23  private ‪$identifier;
24 
28  private ‪$configuration = [];
29 
33  private ‪$resolveArguments = [];
34 
38  private ‪$generateParameters = [];
39 
40  public static function ‪create(string ‪$identifier): self
41  {
42  return new static(‪$identifier);
43  }
44 
45  private function ‪__construct(string ‪$identifier)
46  {
47  $this->identifier = ‪$identifier;
48  }
49 
53  public function ‪getConfiguration()
54  {
56  }
57 
61  public function ‪getResolveArguments(): array
62  {
64  }
65 
69  public function ‪getGenerateParameters(): array
70  {
72  }
73 
74  public function ‪withConfiguration(array ‪$configuration, bool $merge = false): self
75  {
76  $target = clone $this;
77 
78  $target->configuration = $merge ? $this->‪applyMergedItems($this->configuration, ‪$configuration) : ‪$configuration;
79  return $target;
80  }
81 
82  public function ‪withResolveArguments(array ‪$resolveArguments, bool $merge = false): self
83  {
84  $target = clone $this;
85  $target->resolveArguments = $merge ? $this->‪applyMergedItems($this->resolveArguments, ‪$resolveArguments) : ‪$resolveArguments;
86  return $target;
87  }
88 
89  public function ‪withGenerateParameters(array ‪$generateParameters, bool $merge = false): self
90  {
91  $target = clone $this;
92  $target->generateParameters = $merge ? $this->‪applyMergedItems($this->generateParameters, ‪$generateParameters) : ‪$generateParameters;
93  return $target;
94  }
95 
96  public function ‪describe(): string
97  {
98  return ‪$this->identifier;
99  }
100 
101  private function ‪applyMergedItems(array $currentItems, array $additionalItems): array
102  {
103  if (empty($additionalItems)) {
104  return $currentItems;
105  }
106  if ($this->‪hasOnlyNumericKeys($additionalItems)) {
107  return array_merge($currentItems, $additionalItems);
108  }
109  return array_replace_recursive($currentItems, $additionalItems);
110  }
111 
112  private function ‪hasOnlyNumericKeys(array $items): bool
113  {
114  $numericItems = array_filter($items, 'is_int', ARRAY_FILTER_USE_KEY);
115  return !empty($numericItems);
116  }
117 }
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\$generateParameters
‪array $generateParameters
Definition: EnhancerDeclaration.php:34
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\HasResolveArguments
Definition: HasResolveArguments.php:19
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\$configuration
‪array $configuration
Definition: EnhancerDeclaration.php:26
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\$resolveArguments
‪array $resolveArguments
Definition: EnhancerDeclaration.php:30
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\HasGenerateParameters
Definition: HasGenerateParameters.php:19
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\$identifier
‪string $identifier
Definition: EnhancerDeclaration.php:22
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\withConfiguration
‪withConfiguration(array $configuration, bool $merge=false)
Definition: EnhancerDeclaration.php:70
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\applyMergedItems
‪applyMergedItems(array $currentItems, array $additionalItems)
Definition: EnhancerDeclaration.php:97
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\hasOnlyNumericKeys
‪hasOnlyNumericKeys(array $items)
Definition: EnhancerDeclaration.php:108
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Applicable
Definition: Applicable.php:19
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\withResolveArguments
‪withResolveArguments(array $resolveArguments, bool $merge=false)
Definition: EnhancerDeclaration.php:78
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\__construct
‪__construct(string $identifier)
Definition: EnhancerDeclaration.php:41
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\create
‪static create(string $identifier)
Definition: EnhancerDeclaration.php:36
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\getGenerateParameters
‪array getGenerateParameters()
Definition: EnhancerDeclaration.php:65
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\describe
‪describe()
Definition: EnhancerDeclaration.php:92
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\getConfiguration
‪mixed getConfiguration()
Definition: EnhancerDeclaration.php:49
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\withGenerateParameters
‪withGenerateParameters(array $generateParameters, bool $merge=false)
Definition: EnhancerDeclaration.php:85
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder
Definition: Applicable.php:3
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\getResolveArguments
‪array getResolveArguments()
Definition: EnhancerDeclaration.php:57
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration
Definition: EnhancerDeclaration.php:19