Skip to content

Commit 1cc7927

Browse files
Copilotalongosz
andcommitted
Fix DateTrashed FQCN and restore 30-day search example
Co-authored-by: alongosz <[email protected]>
1 parent 1fc5d14 commit 1cc7927

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

docs/search/search_in_trash_reference.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,23 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
5151
use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause;
5252

5353
$query = new Query();
54+
$query->filter = new Criterion\LogicalAnd([
55+
new Criterion\ContentTypeId([2]), // Articles
56+
new Criterion\DateMetadata(
57+
Criterion\DateMetadata::TRASHED,
58+
Criterion\Operator::GTE,
59+
strtotime('-30 days')
60+
)
61+
]);
5462

55-
// Find trashed articles
56-
$query->filter = new Criterion\ContentTypeId([2]);
57-
58-
// Sort by date trashed (most recent first), then by content name
5963
$query->sortClauses = [
60-
new SortClause\DateTrashed(Query::SORT_DESC),
61-
new SortClause\ContentName(Query::SORT_ASC)
64+
new SortClause\Trash\DateTrashed(Query::SORT_DESC),
65+
new SortClause\ContentName(Query::SORT_ASC),
66+
new SortClause\ContentTypeName(Query::SORT_ASC)
6267
];
6368

69+
// Search for articles trashed in the last 30 days
70+
// Results will be sorted by date trashed (most recent first),
71+
// then by content name and Content Type name (alphabetically)
6472
$results = $trashService->findTrashItems($query);
6573
```

0 commit comments

Comments
 (0)