Skip to content

Commit 85c224a

Browse files
committed
New: Add option to ignore filenames
1 parent 3adb115 commit 85c224a

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

Classes/Fusion/RawListImplementation.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ class RawListImplementation extends AbstractFusionObject
6666
*/
6767
protected $assetUsage;
6868

69+
/**
70+
* Internal cache for the ignored filenames.
71+
*
72+
* @var array
73+
*/
74+
protected $ignoreFilenames;
75+
6976
/**
7077
* Internal cache for the used dimensions
7178
*
@@ -83,7 +90,7 @@ class RawListImplementation extends AbstractFusionObject
8390
/**
8491
* Internal cache for the context
8592
*
86-
* @var array
93+
* @var object
8794
*/
8895
protected $context;
8996

@@ -94,6 +101,24 @@ class RawListImplementation extends AbstractFusionObject
94101
*/
95102
protected $currentSiteNodeIdentifierArray;
96103

104+
protected function getIgnoreFilenames(): array
105+
{
106+
$ignoreFilenames = $this->fusionValue('ignoreFilenames');
107+
108+
if (!is_array($ignoreFilenames)) {
109+
return [];
110+
}
111+
112+
$result = [];
113+
foreach ($ignoreFilenames as $ignoredFile => $value) {
114+
if ($value) {
115+
$result[] = strtolower($ignoredFile);
116+
}
117+
}
118+
119+
return array_unique($result);
120+
}
121+
97122
/**
98123
* Returns the items as result of the fusion object.
99124
*
@@ -113,6 +138,7 @@ public function evaluate(): array
113138
$this->workspace = $startingPoint->getWorkspace()->getName();
114139
$this->startingPoint = $startingPoint;
115140
$this->context = $startingPoint->getContext();
141+
$this->ignoreFilenames = $this->getIgnoreFilenames();
116142
if (isset($this->items)) {
117143
return $this->items;
118144
}
@@ -336,7 +362,7 @@ protected function assetHasCorrectMediaType(?AssetInterface $asset): bool
336362
}
337363

338364
/**
339-
* @param array $entityUsage
365+
* @param object $entityUsage
340366
* @return array|null
341367
*/
342368
protected function entityUsage($entityUsage): ?array
@@ -370,6 +396,11 @@ protected function entityUsage($entityUsage): ?array
370396
/** @var AssetInterface $asset */
371397
$asset = $this->assetRepository->findByIdentifier($id);
372398

399+
$filename = strtolower($asset->getResource()->getFilename());
400+
if (in_array($filename, $this->ignoreFilenames)) {
401+
return null;
402+
}
403+
373404
if (!$this->assetHasCorrectMediaType($asset)) {
374405
return null;
375406
}

Configuration/Settings.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ Neos:
88
autoInclude:
99
Garagist.ImageDirectory:
1010
- 'NodeTypes/*'
11+
12+
Garagist:
13+
ImageDirectory:
14+
# List of filenames who should be always ignored. Case-insensitive.
15+
ignoreFilenames:
16+
'favicon.ico': true
17+
'favicon.png': true
18+
'apple-touch-icon.png': true

Resources/Private/Fusion/Helper/RawList.fusion

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ prototype(Garagist.ImageDirectory:Helper.RawList) {
66
# Can be document or asset
77
sortBy = ${null}
88

9+
ignoreFilenames = ${Configuration.setting('Garagist.ImageDirectory.ignoreFilenames')}
10+
911
# Comma seperated list
1012
mediaTypes = 'image/*,video/*'
1113

0 commit comments

Comments
 (0)