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