Skip to content

Commit

Permalink
Init Commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
martineiber committed Sep 16, 2024
1 parent 96a52a2 commit 06d0234
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 13 deletions.
27 changes: 14 additions & 13 deletions doc/03_Grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |



Expand Down
48 changes: 48 additions & 0 deletions src/DataIndex/Filter/UnreferencedDependencyFilter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\DataIndex\Filter;

use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidArgumentException;
use Pimcore\Bundle\StudioBackendBundle\Grid\Column\ColumnType;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\Filter\ColumnFiltersParameterInterface;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\Filter\TagFilterParameterInterface;

/**
* @internal
*/
final class UnreferencedDependencyFilter implements FilterInterface
{
public function apply(mixed $parameters, QueryInterface $query): QueryInterface
{
if (!$parameters instanceof ColumnFiltersParameterInterface) {
return $query;
}

$filter = $parameters->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());
}
}
9 changes: 9 additions & 0 deletions src/DataIndex/Query/AssetQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


}
2 changes: 2 additions & 0 deletions src/DataIndex/Query/QueryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ public function searchByIds(array $ids): self;
* @param array<int> $tags
*/
public function filterTags(array $tags, bool $considerChildTags): self;

//public function filterRequiredBy(int $id): self;
}
2 changes: 2 additions & 0 deletions src/Grid/Column/ColumnType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 06d0234

Please sign in to comment.