|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Aoe\Asdis\Domain\Model\Asset; |
|
4
|
|
|
|
|
5
|
|
|
use Aoe\Asdis\Domain\Model\Asset; |
|
6
|
|
|
use Aoe\Asdis\Domain\Model\Asset\Collection as AssetCollection; |
|
7
|
|
|
use Aoe\Asdis\System\Uri\Filter\Chain; |
|
8
|
|
|
use Aoe\Asdis\System\Uri\Normalizer; |
|
9
|
|
|
use Aoe\Asdis\System\Uri\Filter\ChainFactory; |
|
10
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Factory which builds asset objects and collections. |
|
14
|
|
|
*/ |
|
15
|
|
|
class Factory |
|
16
|
|
|
{ |
|
17
|
|
|
private ?Normalizer $uriNormalizer = null; |
|
18
|
|
|
|
|
19
|
|
|
private ?Chain $filterChain = null; |
|
20
|
|
|
|
|
21
|
2 |
|
public function injectUriNormalizer(Normalizer $uriNormalizer): void |
|
22
|
|
|
{ |
|
23
|
2 |
|
$this->uriNormalizer = $uriNormalizer; |
|
24
|
2 |
|
} |
|
25
|
|
|
|
|
26
|
2 |
|
public function injectFilterChainFactory(ChainFactory $filterChainFactory): void |
|
27
|
|
|
{ |
|
28
|
2 |
|
$this->filterChain = $filterChainFactory->buildChain(); |
|
29
|
2 |
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param array $paths Array of path strings. |
|
33
|
|
|
* @param array $masks Array of mask strings. |
|
34
|
|
|
*/ |
|
35
|
2 |
|
public function createAssetsFromPaths(array $paths, array $masks): Collection |
|
36
|
|
|
{ |
|
37
|
2 |
|
$filteredPaths = $this->filterChain->filter($paths); |
|
|
|
|
|
|
38
|
2 |
|
$paths = array_intersect($paths, $filteredPaths); |
|
39
|
2 |
|
$masks = array_intersect_key($masks, $paths); |
|
40
|
|
|
|
|
41
|
2 |
|
$assets = $this->createAssetCollection(); |
|
42
|
2 |
|
foreach ($paths as $key => $path) { |
|
43
|
2 |
|
$assets->append($this->createAssetFromPath($path, $masks[$key])); |
|
44
|
|
|
} |
|
45
|
2 |
|
return $assets; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
2 |
|
protected function createAssetFromPath(string $path, string $mask): Asset |
|
49
|
|
|
{ |
|
50
|
2 |
|
$asset = $this->createAsset(); |
|
51
|
2 |
|
$asset->setOriginalPath($path); |
|
52
|
2 |
|
$asset->setMask($mask); |
|
53
|
2 |
|
$asset->setNormalizedPath($this->getNormalizedPath($path)); |
|
54
|
2 |
|
return $asset; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
protected function createAsset(): Asset |
|
58
|
|
|
{ |
|
59
|
|
|
return GeneralUtility::makeInstance(Asset::class); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
protected function createAssetCollection(): Collection |
|
63
|
|
|
{ |
|
64
|
|
|
return GeneralUtility::makeInstance(AssetCollection::class); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
2 |
|
private function getNormalizedPath(string $originalPath): string |
|
68
|
|
|
{ |
|
69
|
2 |
|
return $this->uriNormalizer->normalizePath($originalPath); |
|
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.