Skip to content

Commit

Permalink
IBX-8019: Refactored Object State Id criterion
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 committed Mar 25, 2024
1 parent 7e47231 commit 0b9d95b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
8 changes: 1 addition & 7 deletions eZ/Publish/Core/Limitation/ObjectStateLimitationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,7 @@ public function getCriterion(APILimitationValue $value, APIUserReference $curren
return new Criterion\ObjectStateId($groupedLimitationValues[0]);
}

// limitations from different groups require logical AND between them
$criterions = [];
foreach ($groupedLimitationValues as $limitationGroup) {
$criterions[] = new Criterion\ObjectStateId($limitationGroup);
}

return new Criterion\LogicalAnd($criterions);
return new Criterion\ObjectStateId($value->limitationValues);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,19 @@ public function buildQueryConstraint(
FilteringQueryBuilder $queryBuilder,
FilteringCriterion $criterion
): ?string {
$tableAlias = uniqid('osl_');

/** @var \eZ\Publish\API\Repository\Values\Content\Query\Criterion\ObjectStateId $criterion */
$queryBuilder
->join(
->joinOnce(
'content',
Gateway::OBJECT_STATE_LINK_TABLE,
$tableAlias,
'content.id = ' . $tableAlias . '.contentobject_id',
'object_state_link',
'content.id = object_state_link.contentobject_id',
);

$value = (array)$criterion->value;

return $queryBuilder->expr()->in(
$tableAlias . '.contentobject_state_id',
'object_state_link.contentobject_state_id',
$queryBuilder->createNamedParameter($value, Connection::PARAM_INT_ARRAY)
);
}
Expand Down

0 comments on commit 0b9d95b

Please sign in to comment.