handled case domain not found, also in findbyid
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
d1e67fce03
commit
1052e00cf5
@ -76,9 +76,9 @@ class ApikeyRepository
|
||||
/**
|
||||
* @param String $prefix
|
||||
*
|
||||
* @return \App\Entity\Apikey
|
||||
* @return \App\Entity\Apikey|bool
|
||||
*/
|
||||
public function findByPrefix(String $prefix): Apikey
|
||||
public function findByPrefix(String $prefix): Apikey|bool
|
||||
{
|
||||
$sql = "
|
||||
SELECT name, api_token
|
||||
@ -89,8 +89,11 @@ class ApikeyRepository
|
||||
$statement = $this->databaseConnection->getConnection()->prepare(query: $sql);
|
||||
$statement->bindParam(param: ':prefix', var: $prefix);
|
||||
$statement->execute();
|
||||
$result = $statement->fetch(mode: PDO::FETCH_ASSOC);
|
||||
return new Apikey(name: $result['name'], apiTokenPrefix: $result['api_token_prefix'], apiToken: $result['api_token_result'], id: $result['id']);
|
||||
if ($result = $statement->fetch(mode: PDO::FETCH_ASSOC)) {
|
||||
return new Apikey(name: $result['name'], apiTokenPrefix: $result['api_token_prefix'], apiToken: $result['api_token_result'], id: $result['id']);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
exit($e->getMessage());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user