Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rollback Identifiers::lookupPerson function signature as changed by 4…
…b3bc03 for CFM-291
Benn Oshrin committed May 28, 2024
1 parent 0b826a0 commit 462f158
Showing 1 changed file with 11 additions and 26 deletions.
37 changes: 11 additions & 26 deletions app/src/Model/Table/IdentifiersTable.php
@@ -202,32 +202,17 @@ public function localAfterSave(\Cake\Event\EventInterface $event, \Cake\Datasour
* @since COmanage Registry v5.0.0
*/

public function lookupPerson(int $typeId, string $identifier, ?int $coId, bool $login=false): int {
$whereClause = [
'identifier' => $identifier,
'status' => SuspendableStatusEnum::Active,
'person_id IS NOT NULL'
];

if($typeId) {
$whereClause['type_id'] = $typeId;
}

if($login) {
$whereClause['login'] = true;
}

$query = $this->find()
->where($whereClause);

if($coId) {
$query->matching(
'People',
fn(QueryExpression $exp, Query $query) => $query->where(['People.co_id' => $coId])
);
}

$id = $query->firstOrFail();
public function lookupPerson(int $typeId, string $identifier): int {
// Note this function signature is intentionally the same as
// EmailAddresses::lookupPerson()
$id = $this->find()
->where([
'identifier' => $identifier,
'type_id' => $typeId,
'status' => SuspendableStatusEnum::Active,
'person_id IS NOT NULL'
])
->firstOrFail();

return $id->person_id;
}

0 comments on commit 462f158

Please sign in to comment.