mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-11-30 23:37:16 +01:00
More return types
This commit is contained in:
@@ -5,6 +5,8 @@ use OCP\IDBConnection;
|
||||
use OCP\AppFramework\Db\Mapper;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
|
||||
use OCA\QuickNotes\Db\NoteShare;
|
||||
|
||||
class NoteShareMapper extends Mapper {
|
||||
|
||||
public function __construct(IDBConnection $db) {
|
||||
@@ -16,40 +18,43 @@ class NoteShareMapper extends Mapper {
|
||||
return $this->findEntity($sql, [$id, $userId]);
|
||||
}*/
|
||||
|
||||
public function findForUser($userId) {
|
||||
public function findForUser(string $userId): array {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_shares WHERE shared_user = ?';
|
||||
return $this->findEntities($sql, [$userId]);
|
||||
}
|
||||
|
||||
public function findForGroup($groupId) {
|
||||
public function findForGroup($groupId): array {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_shares WHERE shared_group = ?';
|
||||
return $this->findEntities($sql, [$groupId]);
|
||||
}
|
||||
|
||||
public function findByNoteAndUser($noteId, $userId) {
|
||||
public function findByNoteAndUser($noteId, $userId): NoteShare {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_shares WHERE shared_user = ? AND note_id = ?';
|
||||
return $this->findEntity($sql, [$userId, $noteId]);
|
||||
}
|
||||
|
||||
public function findByNoteAndGroup($noteId, $groupId) {
|
||||
public function findByNoteAndGroup($noteId, $groupId): NoteShare {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_shares WHERE shared_group = ? AND note_id = ?';
|
||||
return $this->findEntity($sql, [$groupId, $noteId]);
|
||||
}
|
||||
|
||||
public function getSharesForNote($noteId) {
|
||||
public function getSharesForNote(int $noteId): array {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_shares WHERE note_id = ?';
|
||||
return $this->findEntities($sql, [$noteId]);
|
||||
}
|
||||
|
||||
public function deleteByNoteId($noteId) {
|
||||
public function deleteByNoteId(int $noteId): void {
|
||||
$sql = 'DELETE FROM *PREFIX*quicknotes_shares WHERE note_id = ?';
|
||||
$this->execute($sql, [$noteId]);
|
||||
}
|
||||
|
||||
public function existsByNoteAndUser($noteId, $userId) {
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function existsByNoteAndUser(int $noteId, $userId) {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_shares WHERE shared_user = ? AND note_id = ?';
|
||||
try {
|
||||
return $this->findEntities($sql, [$userId, $noteId]);
|
||||
$this->findEntities($sql, [$userId, $noteId]);
|
||||
} catch (DoesNotExistException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user