- Documentation >
- Search >
- Search in trash reference
Search in trash reference
When you search for content items that are held in trash, you can apply only a limited subset of Search Criteria and Sort Clauses
which can be used by Ibexa\Contracts\Core\Repository\TrashService::findTrashItems
.
Some sort clauses are exclusive to trash search.
Search Criteria
Criterion |
Description |
ContentName |
Find content items by their name |
ContentTypeId |
Find content items by their Content Type ID |
DateMetadata |
Find content items by metadata dates. Can use the additional exclusive target DateMetadata::TRASHED for trash-specific searches |
MatchAll |
Match all content items (no filtering) |
MatchNone |
Match no content items (filter out all) |
SectionId |
Find content items by their Section ID |
UserMetadata |
Find content items by user metadata (creator or modifier) |
Logical operators
Operator |
Description |
LogicalAnd |
Composite criterion to group multiple criteria using the AND condition |
LogicalNot |
Negate the result of the wrapped criterion |
LogicalOr |
Composite criterion to group multiple criteria using the OR condition |
Sort Clauses
Name |
Description |
ContentName |
Sort by content item name |
ContentTypeName |
Sort by Content Type name |
DateTrashed |
Sort by the date when content was moved to trash (exclusive to trash search) |
Depth |
Sort by the original depth in the content tree |
Path |
Sort by the original path in the content tree |
Priority |
Sort by content item priority |
SectionName |
Sort by Section name |
UserLogin |
Sort by the login of the user who created the content |
The following example shows how you can use the criteria and sort clauses to find trashed content items:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause;
$query = new Query();
$query->filter = new Criterion\LogicalAnd([
new Criterion\ContentTypeId([2]), // Articles
new Criterion\DateMetadata(
Criterion\DateMetadata::TRASHED,
Criterion\Operator::GTE,
strtotime('-30 days')
)
]);
$query->sortClauses = [
new SortClause\Trash\DateTrashed(Query::SORT_DESC),
new SortClause\ContentName(Query::SORT_ASC),
new SortClause\Trash\ContentTypeName(Query::SORT_ASC)
];
// Search for articles trashed in the last 30 days
// Results will be sorted by date trashed (most recent first),
// then by content name and Content Type name (alphabetically)
$results = $trashService->findTrashItems($query);
|