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

IBX-8019: Refactored Object State Id criterion #405

Closed
wants to merge 1 commit into from
Closed
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
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
Loading