From 06d02346566587cf2072d89b3dc3a5a9a1363da6 Mon Sep 17 00:00:00 2001 From: Martin Eiber Date: Mon, 16 Sep 2024 14:35:14 +0200 Subject: [PATCH] Init Commit. --- doc/03_Grid.md | 27 ++++++----- .../Filter/UnreferencedDependencyFilter.php | 48 +++++++++++++++++++ src/DataIndex/Query/AssetQuery.php | 9 ++++ src/DataIndex/Query/QueryInterface.php | 2 + src/Grid/Column/ColumnType.php | 2 + 5 files changed, 75 insertions(+), 13 deletions(-) create mode 100644 src/DataIndex/Filter/UnreferencedDependencyFilter.php diff --git a/doc/03_Grid.md b/doc/03_Grid.md index d5621523..64659ede 100644 --- a/doc/03_Grid.md +++ b/doc/03_Grid.md @@ -28,19 +28,20 @@ A `columnFilter` has a reference to the column and the value you want to filter Available filters are: -| Type | filterValue | Options | -|:-----------------:|:-------------------:|:---------------------------:| -| metadata.select | string | | -| metadata.date | object of timestamp | `from`, `to`, or `on` | -| metadata.input | string | | -| metadata.checkbox | boolean | | -| metadata.textarea | string | | -| metadata.object | integer | ID of the object | -| metadata.document | integer | ID fo the document | -| metadata.asset | integer | ID fo the asset | -| system.string | string | Wildcard search can be used | -| system.datetime | integer | `from`, `to`, or `on` | -| system.tag | object | `considerChildTags`, `tags` | +| Type | filterValue | Options | +|:-------------------------------:|:-------------------:|:---------------------------:| +| metadata.select | string | | +| metadata.date | object of timestamp | `from`, `to`, or `on` | +| metadata.input | string | | +| metadata.checkbox | boolean | | +| metadata.textarea | string | | +| metadata.object | integer | ID of the object | +| metadata.document | integer | ID fo the document | +| metadata.asset | integer | ID fo the asset | +| system.string | string | Wildcard search can be used | +| system.datetime | integer | `from`, `to`, or `on` | +| system.tag | object | `considerChildTags`, `tags` | +| system.unreferencedDependencies | boolean | | diff --git a/src/DataIndex/Filter/UnreferencedDependencyFilter.php b/src/DataIndex/Filter/UnreferencedDependencyFilter.php new file mode 100644 index 00000000..5e76666e --- /dev/null +++ b/src/DataIndex/Filter/UnreferencedDependencyFilter.php @@ -0,0 +1,48 @@ +getFirstColumnFilterByType(ColumnType::SYSTEM_UNREFERENCED_DEPENDENCIES->value); + + if (!$filter) { + return $query; + } + + if (!is_bool($filter->getFilterValue())) { + throw new InvalidArgumentException('Filter value for unreferenced dependencies must be a boolean'); + } + + return $query->filterForUnreferencedDependencies($filter->getFilterValue()); + } +} diff --git a/src/DataIndex/Query/AssetQuery.php b/src/DataIndex/Query/AssetQuery.php index e2964166..ddf66f32 100644 --- a/src/DataIndex/Query/AssetQuery.php +++ b/src/DataIndex/Query/AssetQuery.php @@ -156,4 +156,13 @@ public function filterTags(array $tags, bool $considerChildTags): QueryInterface return $this; } + + public function filterRequiredBy(int $id): QueryInterface + { + //$this->search->addModifier(new ($tags, $considerChildTags) + + return $this; + } + + } diff --git a/src/DataIndex/Query/QueryInterface.php b/src/DataIndex/Query/QueryInterface.php index 6f9d5ad6..2d0fa8b1 100644 --- a/src/DataIndex/Query/QueryInterface.php +++ b/src/DataIndex/Query/QueryInterface.php @@ -42,4 +42,6 @@ public function searchByIds(array $ids): self; * @param array $tags */ public function filterTags(array $tags, bool $considerChildTags): self; + + //public function filterRequiredBy(int $id): self; } diff --git a/src/Grid/Column/ColumnType.php b/src/Grid/Column/ColumnType.php index c38d59be..678cd4a4 100644 --- a/src/Grid/Column/ColumnType.php +++ b/src/Grid/Column/ColumnType.php @@ -26,6 +26,8 @@ enum ColumnType: string case SYSTEM_INTEGER = 'system.integer'; case SYSTEM_DATETIME = 'system.datetime'; case SYSTEM_TAG = 'system.tag'; + + case SYSTEM_UNREFERENCED_DEPENDENCIES = 'system.unreferencedDependencies'; case METADATA_SELECT = 'metadata.select'; case METADATA_INPUT = 'metadata.input'; case METADATA_DATE = 'metadata.date';