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