Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Implement ContentId criterion visitor
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/lib/Core/Query/Translator/Criterion/Visitor/ContentId.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cabbage\Core\Query\Translator\Criterion\Visitor; | ||
|
||
use Cabbage\Core\Query\Translator\Criterion\Visitor; | ||
use Cabbage\Core\Query\Translator\Criterion\Converter; | ||
use eZ\Publish\API\Repository\Values\Content\Query\Criterion; | ||
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\ContentId as ContentIdCriterion; | ||
|
||
/** | ||
* Visits ContentId criterion. | ||
* | ||
* @see \eZ\Publish\API\Repository\Values\Content\Query\Criterion\ContentId | ||
*/ | ||
final class ContentId extends Visitor | ||
{ | ||
public function accept(Criterion $criterion): bool | ||
{ | ||
return $criterion instanceof ContentIdCriterion; | ||
} | ||
|
||
public function visit(Criterion $criterion, Converter $converter): array | ||
{ | ||
return [ | ||
'term' => [ | ||
'content_id' => $criterion->value[0], | ||
], | ||
]; | ||
} | ||
} |