mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-11-30 23:37:16 +01:00
Add return types to Attach
This commit is contained in:
@@ -14,15 +14,15 @@ class Attach extends Entity implements JsonSerializable {
|
|||||||
protected $redirectUrl;
|
protected $redirectUrl;
|
||||||
protected $deepLinkUrl;
|
protected $deepLinkUrl;
|
||||||
|
|
||||||
public function setPreviewUrl($previewUrl) {
|
public function setPreviewUrl(string $previewUrl): void {
|
||||||
$this->previewUrl = $previewUrl;
|
$this->previewUrl = $previewUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRedirectUrl($redirectUrl) {
|
public function setRedirectUrl(string $redirectUrl): void {
|
||||||
$this->redirectUrl = $redirectUrl;
|
$this->redirectUrl = $redirectUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDeepLinkUrl($deepLinkUrl) {
|
public function setDeepLinkUrl(string $deepLinkUrl): void {
|
||||||
$this->deepLinkUrl = $deepLinkUrl;
|
$this->deepLinkUrl = $deepLinkUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ use OCP\AppFramework\Db\QBMapper;
|
|||||||
use OCP\AppFramework\Db\DoesNotExistException;
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||||
|
|
||||||
|
use OCA\QuickNotes\Db\Attach;
|
||||||
|
|
||||||
class AttachMapper extends QBMapper {
|
class AttachMapper extends QBMapper {
|
||||||
|
|
||||||
public function __construct(IDBConnection $db) {
|
public function __construct(IDBConnection $db) {
|
||||||
@@ -20,7 +22,7 @@ class AttachMapper extends QBMapper {
|
|||||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
|
||||||
* @return Attach
|
* @return Attach
|
||||||
*/
|
*/
|
||||||
public function find($id, $userId) {
|
public function find($id, $userId): Attach {
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
$qb->select('*')
|
$qb->select('*')
|
||||||
->from($this->tableName)
|
->from($this->tableName)
|
||||||
@@ -31,7 +33,10 @@ class AttachMapper extends QBMapper {
|
|||||||
return $this->findEntity($qb);
|
return $this->findEntity($qb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findAll($userId) {
|
/**
|
||||||
|
* @return Attach[]
|
||||||
|
*/
|
||||||
|
public function findAll($userId): array {
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
$qb->select('*')
|
$qb->select('*')
|
||||||
->from($this->tableName)
|
->from($this->tableName)
|
||||||
@@ -48,7 +53,7 @@ class AttachMapper extends QBMapper {
|
|||||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
|
||||||
* @return Attach
|
* @return Attach
|
||||||
*/
|
*/
|
||||||
public function findFileAttachFromNote($userId, $noteId, $fileId) {
|
public function findFileAttachFromNote($userId, $noteId, $fileId): Attach {
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
$qb->select('*')
|
$qb->select('*')
|
||||||
->from($this->tableName)
|
->from($this->tableName)
|
||||||
@@ -60,13 +65,16 @@ class AttachMapper extends QBMapper {
|
|||||||
return $this->findEntity($qb);
|
return $this->findEntity($qb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fileAttachExists($userId, $noteId, $fileId) {
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function fileAttachExists(string $userId, int $noteId, $fileId): bool {
|
||||||
try {
|
try {
|
||||||
return $this->findFileAttachFromNote($userId, $noteId, $fileId);
|
$this->findFileAttachFromNote($userId, $noteId, $fileId);
|
||||||
} catch (DoesNotExistException $e) {
|
} catch (DoesNotExistException $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +83,7 @@ class AttachMapper extends QBMapper {
|
|||||||
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
|
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
|
||||||
* @return Attach[]
|
* @return Attach[]
|
||||||
*/
|
*/
|
||||||
public function findFromNote($userId, $noteId) {
|
public function findFromNote($userId, $noteId): array {
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
$qb->select('*')
|
$qb->select('*')
|
||||||
->from($this->tableName)
|
->from($this->tableName)
|
||||||
|
|||||||
Reference in New Issue
Block a user