@@ -39,44 +39,44 @@ |
||
39 | 39 | */ |
40 | 40 | class AccessTokenMapper extends QBMapper { |
41 | 41 | |
42 | - /** |
|
43 | - * @param IDBConnection $db |
|
44 | - */ |
|
45 | - public function __construct(IDBConnection $db) { |
|
46 | - parent::__construct($db, 'oauth2_access_tokens'); |
|
47 | - } |
|
42 | + /** |
|
43 | + * @param IDBConnection $db |
|
44 | + */ |
|
45 | + public function __construct(IDBConnection $db) { |
|
46 | + parent::__construct($db, 'oauth2_access_tokens'); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param string $code |
|
51 | - * @return AccessToken |
|
52 | - * @throws AccessTokenNotFoundException |
|
53 | - */ |
|
54 | - public function getByCode(string $code): AccessToken { |
|
55 | - $qb = $this->db->getQueryBuilder(); |
|
56 | - $qb |
|
57 | - ->select('*') |
|
58 | - ->from($this->tableName) |
|
59 | - ->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code)))); |
|
49 | + /** |
|
50 | + * @param string $code |
|
51 | + * @return AccessToken |
|
52 | + * @throws AccessTokenNotFoundException |
|
53 | + */ |
|
54 | + public function getByCode(string $code): AccessToken { |
|
55 | + $qb = $this->db->getQueryBuilder(); |
|
56 | + $qb |
|
57 | + ->select('*') |
|
58 | + ->from($this->tableName) |
|
59 | + ->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code)))); |
|
60 | 60 | |
61 | - try { |
|
62 | - $token = $this->findEntity($qb); |
|
63 | - } catch (IMapperException $e) { |
|
64 | - throw new AccessTokenNotFoundException('Could not find access token', 0, $e); |
|
65 | - } |
|
61 | + try { |
|
62 | + $token = $this->findEntity($qb); |
|
63 | + } catch (IMapperException $e) { |
|
64 | + throw new AccessTokenNotFoundException('Could not find access token', 0, $e); |
|
65 | + } |
|
66 | 66 | |
67 | - return $token; |
|
68 | - } |
|
67 | + return $token; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * delete all access token from a given client |
|
72 | - * |
|
73 | - * @param int $id |
|
74 | - */ |
|
75 | - public function deleteByClientId(int $id) { |
|
76 | - $qb = $this->db->getQueryBuilder(); |
|
77 | - $qb |
|
78 | - ->delete($this->tableName) |
|
79 | - ->where($qb->expr()->eq('client_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
80 | - $qb->executeUpdate(); |
|
81 | - } |
|
70 | + /** |
|
71 | + * delete all access token from a given client |
|
72 | + * |
|
73 | + * @param int $id |
|
74 | + */ |
|
75 | + public function deleteByClientId(int $id) { |
|
76 | + $qb = $this->db->getQueryBuilder(); |
|
77 | + $qb |
|
78 | + ->delete($this->tableName) |
|
79 | + ->where($qb->expr()->eq('client_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
80 | + $qb->executeUpdate(); |
|
81 | + } |
|
82 | 82 | } |
@@ -39,62 +39,62 @@ |
||
39 | 39 | */ |
40 | 40 | class ClientMapper extends QBMapper { |
41 | 41 | |
42 | - /** |
|
43 | - * @param IDBConnection $db |
|
44 | - */ |
|
45 | - public function __construct(IDBConnection $db) { |
|
46 | - parent::__construct($db, 'oauth2_clients'); |
|
47 | - } |
|
42 | + /** |
|
43 | + * @param IDBConnection $db |
|
44 | + */ |
|
45 | + public function __construct(IDBConnection $db) { |
|
46 | + parent::__construct($db, 'oauth2_clients'); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param string $clientIdentifier |
|
51 | - * @return Client |
|
52 | - * @throws ClientNotFoundException |
|
53 | - */ |
|
54 | - public function getByIdentifier(string $clientIdentifier): Client { |
|
55 | - $qb = $this->db->getQueryBuilder(); |
|
56 | - $qb |
|
57 | - ->select('*') |
|
58 | - ->from($this->tableName) |
|
59 | - ->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier))); |
|
49 | + /** |
|
50 | + * @param string $clientIdentifier |
|
51 | + * @return Client |
|
52 | + * @throws ClientNotFoundException |
|
53 | + */ |
|
54 | + public function getByIdentifier(string $clientIdentifier): Client { |
|
55 | + $qb = $this->db->getQueryBuilder(); |
|
56 | + $qb |
|
57 | + ->select('*') |
|
58 | + ->from($this->tableName) |
|
59 | + ->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier))); |
|
60 | 60 | |
61 | - try { |
|
62 | - $client = $this->findEntity($qb); |
|
63 | - } catch (IMapperException $e) { |
|
64 | - throw new ClientNotFoundException('could not find client '.$clientIdentifier, 0, $e); |
|
65 | - } |
|
66 | - return $client; |
|
67 | - } |
|
61 | + try { |
|
62 | + $client = $this->findEntity($qb); |
|
63 | + } catch (IMapperException $e) { |
|
64 | + throw new ClientNotFoundException('could not find client '.$clientIdentifier, 0, $e); |
|
65 | + } |
|
66 | + return $client; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param int $id internal id of the client |
|
71 | - * @return Client |
|
72 | - * @throws ClientNotFoundException |
|
73 | - */ |
|
74 | - public function getByUid(int $id): Client { |
|
75 | - $qb = $this->db->getQueryBuilder(); |
|
76 | - $qb |
|
77 | - ->select('*') |
|
78 | - ->from($this->tableName) |
|
79 | - ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
69 | + /** |
|
70 | + * @param int $id internal id of the client |
|
71 | + * @return Client |
|
72 | + * @throws ClientNotFoundException |
|
73 | + */ |
|
74 | + public function getByUid(int $id): Client { |
|
75 | + $qb = $this->db->getQueryBuilder(); |
|
76 | + $qb |
|
77 | + ->select('*') |
|
78 | + ->from($this->tableName) |
|
79 | + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
80 | 80 | |
81 | - try { |
|
82 | - $client = $this->findEntity($qb); |
|
83 | - } catch (IMapperException $e) { |
|
84 | - throw new ClientNotFoundException('could not find client with id '.$id, 0, $e); |
|
85 | - } |
|
86 | - return $client; |
|
87 | - } |
|
81 | + try { |
|
82 | + $client = $this->findEntity($qb); |
|
83 | + } catch (IMapperException $e) { |
|
84 | + throw new ClientNotFoundException('could not find client with id '.$id, 0, $e); |
|
85 | + } |
|
86 | + return $client; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return Client[] |
|
91 | - */ |
|
92 | - public function getClients(): array { |
|
93 | - $qb = $this->db->getQueryBuilder(); |
|
94 | - $qb |
|
95 | - ->select('*') |
|
96 | - ->from($this->tableName); |
|
89 | + /** |
|
90 | + * @return Client[] |
|
91 | + */ |
|
92 | + public function getClients(): array { |
|
93 | + $qb = $this->db->getQueryBuilder(); |
|
94 | + $qb |
|
95 | + ->select('*') |
|
96 | + ->from($this->tableName); |
|
97 | 97 | |
98 | - return $this->findEntities($qb); |
|
99 | - } |
|
98 | + return $this->findEntities($qb); |
|
99 | + } |
|
100 | 100 | } |