Skip to content

Commit

Permalink
Move IsContainerQueryBuilder from Location to Contnet
Browse files Browse the repository at this point in the history
  • Loading branch information
tischsoic committed Mar 11, 2024
1 parent 1f4dac7 commit d8a24ff
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,46 @@
*/
declare(strict_types=1);

namespace Ibexa\Core\Persistence\Legacy\Filter\CriterionQueryBuilder\Location;
namespace Ibexa\Core\Persistence\Legacy\Filter\CriterionQueryBuilder\Content;

use Doctrine\DBAL\ParameterType;
use Ibexa\Contracts\Core\Persistence\Filter\Doctrine\FilteringQueryBuilder;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\IsContainer;
use Ibexa\Contracts\Core\Repository\Values\Filter\CriterionQueryBuilder;
use Ibexa\Contracts\Core\Repository\Values\Filter\FilteringCriterion;
use Ibexa\Core\Persistence\Legacy\Content\Type\Gateway;

/**
* @internal for internal use by Repository Filtering
*/
final class IsContainerQueryBuilder extends BaseLocationCriterionQueryBuilder
final class IsContainerQueryBuilder implements CriterionQueryBuilder
{
public function accepts(FilteringCriterion $criterion): bool
{
return $criterion instanceof IsContainer;
}

/**
* @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\IsContainer $criterion
*/
public function buildQueryConstraint(
FilteringQueryBuilder $queryBuilder,
FilteringCriterion $criterion
): ?string {
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\IsContainer $criterion */
parent::buildQueryConstraint($queryBuilder, $criterion);

$queryBuilder
->joinOnce(
'content',
Gateway::CONTENT_TYPE_TABLE,
'contentclass',
'content.contentclass_id = contentclass.id',
'content_type',
'content.contentclass_id = content_type.id',
);

/** @var array{bool} $criterionValue */
$criterionValue = $criterion->value;
$isContainer = reset($criterionValue);

return $queryBuilder->expr()->in(
'contentclass.is_container',
'content_type.is_container',
$queryBuilder->createNamedParameter((int)$isContainer, ParameterType::INTEGER)
);
}
Expand Down

0 comments on commit d8a24ff

Please sign in to comment.