Skip to content

Commit 3843b6f

Browse files
authored
Merge pull request #9 from Flowpack/8-feature-exclude-node-types-from-usage-count
FEATURE: Exclude node types from usage count
2 parents f0ddc68 + d437a6d commit 3843b6f

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

Classes/Service/AssetIntegrationService.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ final class AssetIntegrationService
5353
*/
5454
protected $assetUsageLogger;
5555

56+
/**
57+
* @Flow\InjectConfiguration(path="excludedNodeTypes")
58+
* @var array
59+
*/
60+
protected $excludedNodeTypes;
61+
5662
private $assetPropertiesByNodeType = [];
5763

5864
public function assetRemoved(AssetInterface $asset): void
@@ -104,6 +110,13 @@ public function getAssetPropertyNamesForNodeType(NodeType $nodeType): array
104110
return $this->assetPropertiesByNodeType[$nodeType->getName()];
105111
}
106112

113+
foreach ($this->excludedNodeTypes as $excludedNodeType) {
114+
if ($nodeType->isOfType($excludedNodeType)) {
115+
$this->assetPropertiesByNodeType[$nodeType->getName()] = [];
116+
return [];
117+
}
118+
}
119+
107120
$propertyNames = array_reduce(array_keys($nodeType->getProperties()),
108121
function ($carry, $propertyName) use ($nodeType) {
109122
if ($this->propertyTypeCanBeRegistered($nodeType->getPropertyType($propertyName))) {

Configuration/Settings.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Flowpack:
2+
Neos:
3+
AssetUsage:
4+
excludedNodeTypes: []

Readme.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,29 @@ When that happens, it is important that you try to find out where they come from
4646
If you think this happened due to an error in this package, please open an issue
4747
with as much information as you can give.
4848

49+
## Feature: Exclude node types from usage count
50+
51+
Possible use case: If you are using this package in combination with [neos/metadata-contentrepositoryadapter](https://github.com/neos/metadata-contentrepositoryadapter), the metadata entries will be recognized as usage count. You can adjust this behaviour with the following settings.
52+
53+
Example to exclude all metadata node types from usage count:
54+
```
55+
Flowpack:
56+
Neos:
57+
AssetUsage:
58+
excludedNodeTypes:
59+
- 'Neos.MetaData:AbstractMetaData'
60+
```
61+
62+
Example to exclude multiple custom metadata node types:
63+
```
64+
Flowpack:
65+
Neos:
66+
AssetUsage:
67+
excludedNodeTypes:
68+
- 'Vendor.PackageName:Custom.MetaData.NodeType1'
69+
- 'Vendor.PackageName:Custom.MetaData.NodeType2'
70+
```
71+
4972
## Related packages
5073

5174
* [Flowpack.EntityUsage](https://github.com/Flowpack/Flowpack.EntityUsage) the generic usage implementation

0 commit comments

Comments
 (0)