Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement ContentId criterion visitor
  • Loading branch information
pspanja committed Nov 16, 2018
1 parent 43c6952 commit 3d67223
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/lib/Core/Query/Translator/Criterion/Visitor/ContentId.php
@@ -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],
],
];
}
}

0 comments on commit 3d67223

Please sign in to comment.