| @@ 113-126 (lines=14) @@ | ||
| 110 | * @return array |
|
| 111 | * @throws \Exception |
|
| 112 | */ |
|
| 113 | public function getServerById($id) { |
|
| 114 | $query = $this->connection->getQueryBuilder(); |
|
| 115 | $query->select('*')->from($this->dbTable) |
|
| 116 | ->where($query->expr()->eq('id', $query->createParameter('id'))) |
|
| 117 | ->setParameter('id', $id); |
|
| 118 | $query->execute(); |
|
| 119 | $result = $query->execute()->fetchAll(); |
|
| 120 | ||
| 121 | if (empty($result)) { |
|
| 122 | throw new \Exception('No Server found with ID: ' . $id); |
|
| 123 | } |
|
| 124 | ||
| 125 | return $result[0]; |
|
| 126 | } |
|
| 127 | ||
| 128 | /** |
|
| 129 | * get all trusted servers |
|
| @@ 181-195 (lines=15) @@ | ||
| 178 | * @return string |
|
| 179 | * @throws \Exception |
|
| 180 | */ |
|
| 181 | public function getToken($url) { |
|
| 182 | $hash = $this->hash($url); |
|
| 183 | $query = $this->connection->getQueryBuilder(); |
|
| 184 | $query->select('token')->from($this->dbTable) |
|
| 185 | ->where($query->expr()->eq('url_hash', $query->createParameter('url_hash'))) |
|
| 186 | ->setParameter('url_hash', $hash); |
|
| 187 | ||
| 188 | $result = $query->execute()->fetch(); |
|
| 189 | ||
| 190 | if (!isset($result['token'])) { |
|
| 191 | throw new \Exception('No token found for: ' . $url); |
|
| 192 | } |
|
| 193 | ||
| 194 | return $result['token']; |
|
| 195 | } |
|
| 196 | ||
| 197 | /** |
|
| 198 | * add shared Secret to database |
|
| @@ 864-879 (lines=16) @@ | ||
| 861 | * @return string |
|
| 862 | * @throws \InvalidArgumentException |
|
| 863 | */ |
|
| 864 | public function getCardUri($id) { |
|
| 865 | $query = $this->db->getQueryBuilder(); |
|
| 866 | $query->select('uri')->from($this->dbCardsTable) |
|
| 867 | ->where($query->expr()->eq('id', $query->createParameter('id'))) |
|
| 868 | ->setParameter('id', $id); |
|
| 869 | ||
| 870 | $result = $query->execute(); |
|
| 871 | $uri = $result->fetch(); |
|
| 872 | $result->closeCursor(); |
|
| 873 | ||
| 874 | if (!isset($uri['uri'])) { |
|
| 875 | throw new \InvalidArgumentException('Card does not exists: ' . $id); |
|
| 876 | } |
|
| 877 | ||
| 878 | return $uri['uri']; |
|
| 879 | } |
|
| 880 | ||
| 881 | /** |
|
| 882 | * return contact with the given URI |
|