diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2021-03-02 21:08:37 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2021-03-03 12:35:14 +0100 |
commit | ee7702e5f0399b3df9ea739179eab16eb8007f6d (patch) | |
tree | 9304d948c28260c909ea70f93491bcf250842512 /apps/dav/lib/Db | |
parent | f109cf0136b9108b29e6236fc171b8192be5bc30 (diff) | |
download | nextcloud-server-ee7702e5f0399b3df9ea739179eab16eb8007f6d.tar.gz nextcloud-server-ee7702e5f0399b3df9ea739179eab16eb8007f6d.zip |
Move DirectMapper to QBMapper
Mapper has been deprecated for some time now.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/dav/lib/Db')
-rw-r--r-- | apps/dav/lib/Db/DirectMapper.php | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/apps/dav/lib/Db/DirectMapper.php b/apps/dav/lib/Db/DirectMapper.php index f088011d1dc..8192793bb02 100644 --- a/apps/dav/lib/Db/DirectMapper.php +++ b/apps/dav/lib/Db/DirectMapper.php @@ -27,10 +27,13 @@ declare(strict_types=1); namespace OCA\DAV\Db; use OCP\AppFramework\Db\DoesNotExistException; -use OCP\AppFramework\Db\Mapper; +use OCP\AppFramework\Db\QBMapper; use OCP\IDBConnection; -class DirectMapper extends Mapper { +/** + * @template-extends QBMapper<Direct> + */ +class DirectMapper extends QBMapper { public function __construct(IDBConnection $db) { parent::__construct($db, 'directlink', Direct::class); } @@ -44,26 +47,18 @@ class DirectMapper extends Mapper { $qb = $this->db->getQueryBuilder(); $qb->select('*') - ->from('directlink') + ->from($this->getTableName()) ->where( $qb->expr()->eq('token', $qb->createNamedParameter($token)) ); - $cursor = $qb->execute(); - $data = $cursor->fetch(); - $cursor->closeCursor(); - - if ($data === false) { - throw new DoesNotExistException('Direct link with token does not exist'); - } - - return Direct::fromRow($data); + return parent::findEntity($qb); } public function deleteExpired(int $expiration) { $qb = $this->db->getQueryBuilder(); - $qb->delete('directlink') + $qb->delete($this->getTableName()) ->where( $qb->expr()->lt('expiration', $qb->createNamedParameter($expiration)) ); |