Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"league/csv": "^9.27",
"nesbot/carbon": "^3.8.4",
"pimcore/static-resolver-bundle": "^3.6.1 ",
"pimcore/generic-data-index-bundle": "^2.5.0",
"pimcore/pimcore": "^12.3",
"pimcore/generic-data-index-bundle": "^2.5.3",
"pimcore/pimcore": "^12.3.9",
"zircote/swagger-php": "^4.8 || ^5.0",
"ext-zip": "*",
"symfony/mercure": "^0.6.5",
Expand Down
4 changes: 4 additions & 0 deletions config/data_index_filters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,7 @@ services:

Pimcore\Bundle\StudioBackendBundle\DataIndex\Filter\DataObject\CRM\ConsentFilter:
tags: [ 'pimcore.studio_backend.search_index.data_object.filter' ]

# Asset
Pimcore\Bundle\StudioBackendBundle\DataIndex\Filter\Asset\UnreferencedFilter:
tags: [ 'pimcore.studio_backend.search_index.asset.filter' ]
13 changes: 13 additions & 0 deletions doc/01_Architecture_Overview/01_Grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ Available filters are:
| classificationstore.number | object | `from`, `to`, `is`, `setting` | true |
| crm.consent | array | `true` or `false` | true |
| dataobject.relation | array | array of `type`, `ids` objects | true |
| system.unreferenced | boolean | Asset grid only — unreferenced assets | false |


### Examples:
Expand Down Expand Up @@ -242,6 +243,18 @@ To filter by this structure:
...
```

Filter unreferenced assets (asset grid only):
```json
...
"columnFilters" [
{
"type": "system.unreferenced",
"filterValue": true
}
]
...
```

## Advanced Columns

Advanced columns combine multiple data sources and transformers. Data source types:
Expand Down
49 changes: 49 additions & 0 deletions src/DataIndex/Filter/Asset/UnreferencedFilter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StudioBackendBundle\DataIndex\Filter\Asset;

use Pimcore\Bundle\StudioBackendBundle\DataIndex\Filter\FilterInterface;
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\AssetQueryInterface;
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface;
use Pimcore\Bundle\StudioBackendBundle\Grid\Column\ColumnType;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\Filter\SimpleColumnFiltersParameterInterface;

/**
* @internal
*/
final class UnreferencedFilter implements FilterInterface
{
public function apply(mixed $parameters, QueryInterface $query): QueryInterface

Check notice on line 27 in src/DataIndex/Filter/Asset/UnreferencedFilter.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/DataIndex/Filter/Asset/UnreferencedFilter.php#L27

Expected 2 blank lines before function; 0 found
{
if (!$parameters instanceof SimpleColumnFiltersParameterInterface) {
return $query;
}

if (!$query instanceof AssetQueryInterface) {
return $query;
}

$filter = $parameters->getSimpleColumnFilterByType(ColumnType::SYSTEM_UNREFERENCED->value);

if ($filter === null) {
return $query;
}

if ($filter->getFilterValue() === true) {
$query->filterUnreferenced();
}

return $query;
}

Check notice on line 48 in src/DataIndex/Filter/Asset/UnreferencedFilter.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/DataIndex/Filter/Asset/UnreferencedFilter.php#L48

Expected 1 blank line before closing function brace; 0 found

Check notice on line 48 in src/DataIndex/Filter/Asset/UnreferencedFilter.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/DataIndex/Filter/Asset/UnreferencedFilter.php#L48

Expected 2 blank lines after function; 0 found
}
8 changes: 8 additions & 0 deletions src/DataIndex/Query/AssetQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Modifier\Filter\Basic\IdsFilter;
use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Modifier\Filter\Basic\IntegerFilter;
use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Modifier\Filter\Basic\NumberFilter;
use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Modifier\Filter\Dependency\UnreferencedFilter;
use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Modifier\Filter\FieldType\BooleanMultiSelectFilter;
use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Modifier\Filter\FieldType\DateFilter;
use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Modifier\Filter\FieldType\MultiSelectFilter;
Expand Down Expand Up @@ -128,6 +129,13 @@ public function filterMetadata(string $name, string $type, mixed $data): self
return $this;
}

public function filterUnreferenced(): self
{
$this->search->addModifier(new UnreferencedFilter());

return $this;
}

public function orderByField(string $fieldName, SortDirection $direction): self
{
$this->search->addModifier(new OrderByField($fieldName, $direction));
Expand Down
2 changes: 2 additions & 0 deletions src/DataIndex/Query/AssetQueryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@
{
public function filterMetadata(string $name, string $type, mixed $data): self;

public function filterUnreferenced(): self;

Check notice on line 25 in src/DataIndex/Query/AssetQueryInterface.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/DataIndex/Query/AssetQueryInterface.php#L25

Expected 2 blank lines after function; 1 found

public function getSearch(): AssetSearchInterface;
}
1 change: 1 addition & 0 deletions src/Grid/Column/ColumnType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum ColumnType: string
case SYSTEM_TIME = 'system.time';
case SYSTEM_DATE = 'system.date';
case SYSTEM_BOOLEAN = 'system.boolean';
case SYSTEM_UNREFERENCED = 'system.unreferenced';
case SYSTEM_TAG = 'system.tag';
case SYSTEM_PQL_QUERY = 'system.pql';
case SYSTEM_NUMBER = 'system.number';
Expand Down
Loading