Skip to content

Collaboration Search Sort Clauses reference

Sort Clauses are found in the Ibexa\Contracts\Collaboration\Value\Query\SortClause namespace.

Invitation Search Sort Clauses

Invitation Search Sort Clauses are implementing the SortClauseInterface interface:

Name Description
CreatedAt Sort by invitation's creation date
Id Sort by invitation's ID
Status Sort by invitation's status
UpdatedAt Sort by the date and time when invitation was updated

Session Search Sort Clauses

Session Search Sort Clauses are implementing the SortClauseInterface interface:

Name Description
CreatedAt Sort by session's creation date
Id Sort by session's ID
UpdatedAt Sort by the date and time when session was updated

Example

The following example shows how to use them to sort the searched sessions:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
declare(strict_types=1);

use Ibexa\Contracts\Collaboration\Session\Query\Criterion;
use Ibexa\Contracts\Collaboration\Session\Query\SortClause;
use Ibexa\Contracts\Collaboration\Session\SessionQuery;
use Ibexa\Contracts\CoreSearch\Values\Query\Criterion\FieldValueCriterion;
use Ibexa\Contracts\CoreSearch\Values\Query\SortClause\FieldValueSortClause;

$lastWeek = new DateTimeImmutable('-7 days');
$query = new SessionQuery(
    new Criterion\LogicalAnd(
        new Criterion\IsActive(true),
        new Criterion\Type('content'),
        new Criterion\CreatedAt($lastWeek, FieldValueCriterion::COMPARISON_GTE),
    ),
    [
        new SortClause\CreatedAt(FieldValueSortClause::SORT_DESC),
    ]
);
/** @var \Ibexa\Contracts\Collaboration\SessionServiceInterface $sessionService */
$sessionList = $sessionService->findSessions($query);

The returned active sessions are sorted by creation date (descending).