mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-19 20:28:06 +00:00
Refactor PersonACLAwareRepository to simplify condition handling in search clause construction
- Replaced `count` check with an `empty` comparison for clarity. - Streamlined conditional logic for search clause initialization. - Removed unnecessary `isset` check before applying `andWhereClause`.
This commit is contained in:
@@ -169,8 +169,10 @@ final readonly class PersonACLAwareRepository implements PersonACLAwareRepositor
|
||||
|
||||
if (null !== $phonenumber) {
|
||||
$personPhoneClause = "person.phonenumber LIKE '%' || ? || '%' OR person.mobilenumber LIKE '%' || ? || '%' OR EXISTS (SELECT 1 FROM chill_person_phone where person_id = person.id AND phonenumber LIKE '%' || ? || '%')";
|
||||
if (count($andWhereSearchClauseArgs) > 0) {
|
||||
if ([] !== $andWhereSearchClauseArgs) {
|
||||
$initialSearchClause = '(('.\implode(' AND ', $andWhereSearchClause).') OR '.$personPhoneClause.')';
|
||||
} else {
|
||||
$initialSearchClause = $personPhoneClause;
|
||||
}
|
||||
$andWhereSearchClauseArgs = [...$andWhereSearchClauseArgs, $phonenumber, $phonenumber, $phonenumber];
|
||||
|
||||
@@ -181,12 +183,10 @@ final readonly class PersonACLAwareRepository implements PersonACLAwareRepositor
|
||||
$initialSearchClause = \implode(' AND ', $andWhereSearchClause);
|
||||
}
|
||||
|
||||
if (isset($initialSearchClause)) {
|
||||
$query->andWhereClause(
|
||||
$initialSearchClause,
|
||||
$andWhereSearchClauseArgs
|
||||
);
|
||||
}
|
||||
$query->andWhereClause(
|
||||
$initialSearchClause,
|
||||
$andWhereSearchClauseArgs
|
||||
);
|
||||
|
||||
$query
|
||||
->setSelectPertinence(\implode(' + ', $pertinence), $pertinenceArgs);
|
||||
|
||||
Reference in New Issue
Block a user