Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added criteria mappers for FieldValueCriterion, LogicalAnd and LogicalOr #5

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/bundle/Resources/config/services/query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@ services:
Ibexa\Contracts\CoreSearch\Values\Query\CriterionMapper:
arguments:
$mappers: !tagged_iterator ibexa.core_search.criterion_mapper

Ibexa\CoreSearch\CriterionMapper\FieldValueCriterionMapper:
tags:
- { name: ibexa.core_search.criterion_mapper, priority: -100 }

Ibexa\CoreSearch\CriterionMapper\LogicalAndCriterionMapper:
tags:
- { name: ibexa.core_search.criterion_mapper, priority: -100 }

Ibexa\CoreSearch\CriterionMapper\LogicalOrCriterionMapper:
tags:
- { name: ibexa.core_search.criterion_mapper, priority: -100 }
26 changes: 26 additions & 0 deletions src/lib/CriterionMapper/FieldValueCriterionMapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\CoreSearch\CriterionMapper;

use Ibexa\Contracts\CoreSearch\Persistence\CriterionMapper\AbstractFieldCriterionMapper;
use Ibexa\Contracts\CoreSearch\Values\Query\Criterion\CriterionInterface;
use Ibexa\Contracts\CoreSearch\Values\Query\Criterion\FieldValueCriterion;

/**
* @template-extends \Ibexa\Contracts\CoreSearch\Persistence\CriterionMapper\AbstractFieldCriterionMapper<
* \Ibexa\Contracts\CoreSearch\Values\Query\Criterion\FieldValueCriterion
* >
*/
final class FieldValueCriterionMapper extends AbstractFieldCriterionMapper
{
public function canHandle(CriterionInterface $criterion): bool
{
return $criterion instanceof FieldValueCriterion;
}
}
26 changes: 26 additions & 0 deletions src/lib/CriterionMapper/LogicalAndCriterionMapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\CoreSearch\CriterionMapper;

use Doctrine\Common\Collections\Expr\CompositeExpression;
use Ibexa\Contracts\CoreSearch\Persistence\CriterionMapper\AbstractCompositeCriterionMapper;
use Ibexa\Contracts\CoreSearch\Values\Query\Criterion\LogicalAnd;

final class LogicalAndCriterionMapper extends AbstractCompositeCriterionMapper
{
protected function getHandledClass(): string
{
return LogicalAnd::class;
}

protected function getType(): string
{
return CompositeExpression::TYPE_AND;
}
}
26 changes: 26 additions & 0 deletions src/lib/CriterionMapper/LogicalOrCriterionMapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\CoreSearch\CriterionMapper;

use Doctrine\Common\Collections\Expr\CompositeExpression;
use Ibexa\Contracts\CoreSearch\Persistence\CriterionMapper\AbstractCompositeCriterionMapper;
use Ibexa\Contracts\CoreSearch\Values\Query\Criterion\LogicalOr;

final class LogicalOrCriterionMapper extends AbstractCompositeCriterionMapper
{
protected function getHandledClass(): string
{
return LogicalOr::class;
}

protected function getType(): string
{
return CompositeExpression::TYPE_OR;
}
}
Loading