| @@ 151-160 (lines=10) @@ | ||
| 148 | * @param string $url |
|
| 149 | * @return bool |
|
| 150 | */ |
|
| 151 | public function serverExists($url) { |
|
| 152 | $hash = $this->hash($url); |
|
| 153 | $query = $this->connection->getQueryBuilder(); |
|
| 154 | $query->select('url')->from($this->dbTable) |
|
| 155 | ->where($query->expr()->eq('url_hash', $query->createParameter('url_hash'))) |
|
| 156 | ->setParameter('url_hash', $hash); |
|
| 157 | $result = $query->execute()->fetchAll(); |
|
| 158 | ||
| 159 | return !empty($result); |
|
| 160 | } |
|
| 161 | ||
| 162 | /** |
|
| 163 | * write token to database. Token is used to exchange the secret |
|
| @@ 168-177 (lines=10) @@ | ||
| 165 | * @param string $url |
|
| 166 | * @param string $token |
|
| 167 | */ |
|
| 168 | public function addToken($url, $token) { |
|
| 169 | $hash = $this->hash($url); |
|
| 170 | $query = $this->connection->getQueryBuilder(); |
|
| 171 | $query->update($this->dbTable) |
|
| 172 | ->set('token', $query->createParameter('token')) |
|
| 173 | ->where($query->expr()->eq('url_hash', $query->createParameter('url_hash'))) |
|
| 174 | ->setParameter('url_hash', $hash) |
|
| 175 | ->setParameter('token', $token); |
|
| 176 | $query->execute(); |
|
| 177 | } |
|
| 178 | ||
| 179 | /** |
|
| 180 | * get token stored in database |
|
| @@ 208-217 (lines=10) @@ | ||
| 205 | * @param string $url |
|
| 206 | * @param string $sharedSecret |
|
| 207 | */ |
|
| 208 | public function addSharedSecret($url, $sharedSecret) { |
|
| 209 | $hash = $this->hash($url); |
|
| 210 | $query = $this->connection->getQueryBuilder(); |
|
| 211 | $query->update($this->dbTable) |
|
| 212 | ->set('shared_secret', $query->createParameter('sharedSecret')) |
|
| 213 | ->where($query->expr()->eq('url_hash', $query->createParameter('url_hash'))) |
|
| 214 | ->setParameter('url_hash', $hash) |
|
| 215 | ->setParameter('sharedSecret', $sharedSecret); |
|
| 216 | $query->execute(); |
|
| 217 | } |
|
| 218 | ||
| 219 | /** |
|
| 220 | * get shared secret from database |
|
| @@ 225-234 (lines=10) @@ | ||
| 222 | * @param string $url |
|
| 223 | * @return string |
|
| 224 | */ |
|
| 225 | public function getSharedSecret($url) { |
|
| 226 | $hash = $this->hash($url); |
|
| 227 | $query = $this->connection->getQueryBuilder(); |
|
| 228 | $query->select('shared_secret')->from($this->dbTable) |
|
| 229 | ->where($query->expr()->eq('url_hash', $query->createParameter('url_hash'))) |
|
| 230 | ->setParameter('url_hash', $hash); |
|
| 231 | ||
| 232 | $result = $query->execute()->fetch(); |
|
| 233 | return $result['shared_secret']; |
|
| 234 | } |
|
| 235 | ||
| 236 | /** |
|
| 237 | * set server status |
|
| @@ 261-270 (lines=10) @@ | ||
| 258 | * @param string $url |
|
| 259 | * @return int |
|
| 260 | */ |
|
| 261 | public function getServerStatus($url) { |
|
| 262 | $hash = $this->hash($url); |
|
| 263 | $query = $this->connection->getQueryBuilder(); |
|
| 264 | $query->select('status')->from($this->dbTable) |
|
| 265 | ->where($query->expr()->eq('url_hash', $query->createParameter('url_hash'))) |
|
| 266 | ->setParameter('url_hash', $hash); |
|
| 267 | ||
| 268 | $result = $query->execute()->fetch(); |
|
| 269 | return (int)$result['status']; |
|
| 270 | } |
|
| 271 | ||
| 272 | /** |
|
| 273 | * create hash from URL |
|
| @@ 139-153 (lines=15) @@ | ||
| 136 | * @return string[] |
|
| 137 | * @codeCoverageIgnore - no need to test this |
|
| 138 | */ |
|
| 139 | public function getMigratedVersions() { |
|
| 140 | $this->createMigrationTable(); |
|
| 141 | $qb = $this->connection->getQueryBuilder(); |
|
| 142 | ||
| 143 | $qb->select('version') |
|
| 144 | ->from('migrations') |
|
| 145 | ->where($qb->expr()->eq('app', $qb->createNamedParameter($this->getApp()))) |
|
| 146 | ->orderBy('version'); |
|
| 147 | ||
| 148 | $result = $qb->execute(); |
|
| 149 | $rows = $result->fetchAll(\PDO::FETCH_COLUMN); |
|
| 150 | $result->closeCursor(); |
|
| 151 | ||
| 152 | return $rows; |
|
| 153 | } |
|
| 154 | ||
| 155 | /** |
|
| 156 | * Returns all versions which are available in the migration folder |
|