summaryrefslogtreecommitdiffstats
path: root/lib/Db/Feed.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Db/Feed.php')
-rw-r--r--lib/Db/Feed.php653
1 files changed, 533 insertions, 120 deletions
diff --git a/lib/Db/Feed.php b/lib/Db/Feed.php
index 7541ac545..898a93718 100644
--- a/lib/Db/Feed.php
+++ b/lib/Db/Feed.php
@@ -13,110 +13,268 @@
namespace OCA\News\Db;
-use \OCP\AppFramework\Db\Entity;
+use OCP\AppFramework\Db\Entity;
-/**
- * @method integer getId()
- * @method void setId(integer $value)
- * @method string getUserId()
- * @method void setUserId(string $value)
- * @method int getOrdering()
- * @method void setOrdering(integer $value)
- * @method string getUrlHash()
- * @method void setUrlHash(string $value)
- * @method string getLocation()
- * @method void setLocation(string $value)
- * @method string getUrl()
- * @method string getTitle()
- * @method void setTitle(string $value)
- * @method string getLastModified()
- * @method void setLastModified(string $value)
- * @method string getHttpLastModified()
- * @method void setHttpLastModified(string $value)
- * @method string getHttpEtag()
- * @method void setHttpEtag(string $value)
- * @method string getFaviconLink()
- * @method void setFaviconLink(string $value)
- * @method integer getAdded()
- * @method void setAdded(integer $value)
- * @method boolean getPinned()
- * @method void setPinned(boolean $value)
- * @method integer getFolderId()
- * @method void setFolderId(integer $value)
- * @method integer getFullTextEnabled()
- * @method void setFullTextEnabled(bool $value)
- * @method integer getUnreadCount()
- * @method void setUnreadCount(integer $value)
- * @method string getLink()
- * @method boolean getPreventUpdate()
- * @method void setPreventUpdate(boolean $value)
- * @method integer getDeletedAt()
- * @method void setDeletedAt(integer $value)
- * @method integer getArticlesPerUpdate()
- * @method void setArticlesPerUpdate(integer $value)
- * @method integer getUpdateErrorCount()
- * @method void setUpdateErrorCount(integer $value)
- * @method string getLastUpdateError()
- * @method void setLastUpdateError(string $value)
- * @method string getBasicAuthUser()
- * @method void setBasicAuthUser(string $value)
- * @method string getBasicAuthPassword()
- * @method void setBasicAuthPassword(string $value)
- */
class Feed extends Entity implements IAPI, \JsonSerializable
{
use EntityJSONSerializer;
- protected $userId;
+ /** @var string */
+ protected $userId = '';
+ /** @var string */
protected $urlHash;
+ /** @var string */
protected $url;
+ /** @var string */
protected $title;
- protected $faviconLink;
- protected $added;
+ /** @var string|null */
+ protected $faviconLink = null;
+ /** @var int|null */
+ protected $added = 0;
+ /** @var int */
protected $folderId;
+ /** @var int */
protected $unreadCount;
- protected $link;
- protected $preventUpdate;
- protected $deletedAt;
- protected $articlesPerUpdate;
- protected $httpLastModified;
- protected $lastModified;
- protected $httpEtag;
- protected $location;
- protected $ordering;
- protected $fullTextEnabled;
- protected $pinned;
- protected $updateMode;
- protected $updateErrorCount;
- protected $lastUpdateError;
- protected $basicAuthUser;
- protected $basicAuthPassword;
-
- public function __construct()
- {
- $this->addType('parentId', 'integer');
- $this->addType('added', 'integer');
- $this->addType('folderId', 'integer');
- $this->addType('unreadCount', 'integer');
- $this->addType('preventUpdate', 'boolean');
- $this->addType('pinned', 'boolean');
- $this->addType('deletedAt', 'integer');
- $this->addType('articlesPerUpdate', 'integer');
- $this->addType('ordering', 'integer');
- $this->addType('fullTextEnabled', 'boolean');
- $this->addType('updateMode', 'integer');
- $this->addType('updateErrorCount', 'integer');
- }
-
-
- /**
- * Turns entitie attributes into an array
- */
- public function jsonSerialize()
- {
- $serialized = $this->serializeFields(
- [
+ /** @var string|null */
+ protected $link = null;
+ /** @var bool */
+ protected $preventUpdate = false;
+ /** @var int|null */
+ protected $deletedAt = 0;
+ /** @var int */
+ protected $articlesPerUpdate = 0;
+ /** @var string|null */
+ protected $httpLastModified = null;
+ /** @var int|null */
+ protected $lastModified = 0;
+ /** @var string|null */
+ protected $httpEtag = null;
+ /** @var string|null */
+ protected $location = null;
+ /** @var int */
+ protected $ordering = 0;
+ /** @var bool */
+ protected $fullTextEnabled = false;
+ /** @var bool */
+ protected $pinned = false;
+ /** @var int */
+ protected $updateMode = 0;
+ /** @var int */
+ protected $updateErrorCount = 0;
+ /** @var string|null */
+ protected $lastUpdateError = '';
+ /** @var string|null */
+ protected $basicAuthUser = '';
+ /** @var string|null */
+ protected $basicAuthPassword = '';
+
+ /**
+ * @return int|null
+ */
+ public function getAdded()
+ {
+ return $this->added;
+ }
+
+ /**
+ * @return int
+ */
+ public function getArticlesPerUpdate(): int
+ {
+ return $this->articlesPerUpdate;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getBasicAuthPassword()
+ {
+ return $this->basicAuthPassword;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getBasicAuthUser()
+ {
+ return $this->basicAuthUser;
+ }
+
+ /**
+ * @return int|null
+ */
+ public function getDeletedAt()
+ {
+ return $this->deletedAt;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getFaviconLink()
+ {
+ return $this->faviconLink;
+ }
+
+ /**
+ * @return int
+ */
+ public function getFolderId(): int
+ {
+ return $this->folderId;
+ }
+
+ /**
+ * @return bool
+ */
+ public function getFullTextEnabled(): bool
+ {
+ return $this->fullTextEnabled;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getHttpEtag()
+ {
+ return $this->httpEtag;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getHttpLastModified()
+ {
+ return $this->httpLastModified;
+ }
+
+ /**
+ * @return int
+ */
+ public function getId(): int
+ {
+ return $this->id;
+ }
+
+ /**
+ * @return int|null
+ */
+ public function getLastModified()
+ {
+ return $this->lastModified;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getLastUpdateError()
+ {
+ return $this->lastUpdateError;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getLink()
+ {
+ return $this->link;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getLocation()
+ {
+ return $this->location;
+ }
+
+ /**
+ * @return int
+ */
+ public function getOrdering(): int
+ {
+ return $this->ordering;
+ }
+
+ /**
+ * @return bool
+ */
+ public function getPinned(): bool
+ {
+ return $this->pinned;
+ }
+
+ /**
+ * @return bool
+ */
+ public function getPreventUpdate(): bool
+ {
+ return $this->preventUpdate;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTitle(): string
+ {
+ return $this->title;
+ }
+
+ /**
+ * @return int
+ */
+ public function getUnreadCount(): int
+ {
+ return $this->unreadCount;
+ }
+
+ /**
+ * @return int
+ */
+ public function getUpdateErrorCount(): int
+ {
+ return $this->updateErrorCount;
+ }
+
+ /**
+ * @return int
+ */
+ public function getUpdateMode(): int
+ {
+ return $this->updateMode;
+ }
+
+ /**
+ * @return string
+ */
+ public function getUrl(): string
+ {
+ return $this->url;
+ }
+
+ /**
+ * @return string
+ */
+ public function getUrlHash(): string
+ {
+ return $this->urlHash;
+ }
+
+ /**
+ * @return string
+ */
+ public function getUserId(): string
+ {
+ return $this->userId;
+ }
+
+ /**
+ * Turns entity attributes into an array
+ */
+ public function jsonSerialize(): array
+ {
+ $serialized = $this->serializeFields([
'id',
'userId',
'urlHash',
@@ -139,8 +297,7 @@ class Feed extends Entity implements IAPI, \JsonSerializable
'lastUpdateError',
'basicAuthUser',
'basicAuthPassword'
- ]
- );
+ ]);
$url = parse_url($this->link, PHP_URL_HOST);
@@ -154,45 +311,301 @@ class Feed extends Entity implements IAPI, \JsonSerializable
return $serialized;
}
+ /**
+ * @param int|null $added
+ */
+ public function setAdded(int $added = null)
+ {
+ if ($this->added !== $added) {
+ $this->added = $added;
+ $this->markFieldUpdated('added');
+ }
+ }
- public function toAPI()
+ /**
+ * @param int $articlesPerUpdate
+ */
+ public function setArticlesPerUpdate(int $articlesPerUpdate)
{
- return $this->serializeFields(
- [
- 'id',
- 'url',
- 'title',
- 'faviconLink',
- 'added',
- 'folderId',
- 'unreadCount',
- 'ordering',
- 'link',
- 'pinned',
- 'updateErrorCount',
- 'lastUpdateError'
- ]
- );
+ if ($this->articlesPerUpdate !== $articlesPerUpdate) {
+ $this->articlesPerUpdate = $articlesPerUpdate;
+ $this->markFieldUpdated('articlesPerUpdate');
+ }
}
+ /**
+ * @param string|null $basicAuthPassword
+ */
+ public function setBasicAuthPassword(string $basicAuthPassword = null)
+ {
+ if ($this->basicAuthPassword !== $basicAuthPassword) {
+ $this->basicAuthPassword = $basicAuthPassword;
+ $this->markFieldUpdated('basicAuthPassword');
+ }
+ }
- public function setUrl($url)
+ /**
+ * @param string|null $basicAuthUser
+ */
+ public function setBasicAuthUser(string $basicAuthUser = null)
{
- $url = trim($url);
- if(strpos($url, 'http') === 0) {
- parent::setUrl($url);
- $this->setUrlHash(md5($url));
+ if ($this->basicAuthUser !== $basicAuthUser) {
+ $this->basicAuthUser = $basicAuthUser;
+ $this->markFieldUpdated('basicAuthUser');
+ }
+ }
+
+ /**
+ * @param int|null $deletedAt
+ */
+ public function setDeletedAt(int $deletedAt = null)
+ {
+ if ($this->deletedAt !== $deletedAt) {
+ $this->deletedAt = $deletedAt;
+ $this->markFieldUpdated('deletedAt');
+ }
+ }
+
+ /**
+ * @param string|null $faviconLink
+ */
+ public function setFaviconLink(string $faviconLink = null)
+ {
+ if ($this->faviconLink !== $faviconLink) {
+ $this->faviconLink = $faviconLink;
+ $this->markFieldUpdated('faviconLink');
+ }
+ }
+
+ /**
+ * @param int $folderId
+ */
+ public function setFolderId(int $folderId)
+ {
+ if ($this->folderId !== $folderId) {
+ $this->folderId = $folderId;
+ $this->markFieldUpdated('folderId');
+ }
+ }
+
+ /**
+ * @param bool $fullTextEnabled
+ */
+ public function setFullTextEnabled(bool $fullTextEnabled)
+ {
+ if ($this->fullTextEnabled !== $fullTextEnabled) {
+ $this->fullTextEnabled = $fullTextEnabled;
+ $this->markFieldUpdated('fullTextEnabled');
+ }
+ }
+
+ /**
+ * @param string|null $httpEtag
+ */
+ public function setHttpEtag(string $httpEtag = null)
+ {
+ if ($this->httpEtag !== $httpEtag) {
+ $this->httpEtag = $httpEtag;
+ $this->markFieldUpdated('httpEtag');
+ }
+ }
+
+ /**
+ * @param string|null $httpLastModified
+ */
+ public function setHttpLastModified(string $httpLastModified = null)
+ {
+ if ($this->httpLastModified !== $httpLastModified) {
+ $this->httpLastModified = $httpLastModified;
+ $this->markFieldUpdated('httpLastModified');
+ }
+ }
+
+ /**
+ * @param int $id
+ */
+ public function setId(int $id)
+ {
+ if ($this->id !== $id) {
+ $this->id = $id;
+ $this->markFieldUpdated('id');
+ }
+ }
+
+ /**
+ * @param int|null $lastModified
+ */
+ public function setLastModified(int $lastModified = null)
+ {
+ if ($this->lastModified !== $lastModified) {
+ $this->lastModified = $lastModified;
+ $this->markFieldUpdated('lastModified');
+ }
+ }
+
+ /**
+ * @param string|null $lastUpdateError
+ */
+ public function setLastUpdateError(string $lastUpdateError = null)
+ {
+ if ($this->lastUpdateError !== $lastUpdateError) {
+ $this->lastUpdateError = $lastUpdateError;
+ $this->markFieldUpdated('lastUpdateError');
}
}
+ /**
+ * @param string|null $link
+ */
+ public function setLink(string $link = null)
+ {
+ $link = trim($link);
+ if (strpos($link, 'http') === 0 && $this->link !== $link) {
+ $this->link = $link;
+ $this->markFieldUpdated('link');
+ }
+ }
- public function setLink($url)
+ /**
+ * @param string|null $location
+ */
+ public function setLocation(string $location = null)
+ {
+ if ($this->location !== $location) {
+ $this->location = $location;
+ $this->markFieldUpdated('location');
+ }
+ }
+
+ /**
+ * @param int $ordering
+ */
+ public function setOrdering(int $ordering)
+ {
+ if ($this->ordering !== $ordering) {
+ $this->ordering = $ordering;
+ $this->markFieldUpdated('ordering');
+ }
+ }
+
+ /**
+ * @param bool $pinned
+ */
+ public function setPinned(bool $pinned)
+ {
+ if ($this->pinned !== $pinned) {
+ $this->pinned = $pinned;
+ $this->markFieldUpdated('pinned');
+ }
+ }
+
+ /**
+ * @param bool $preventUpdate
+ */
+ public function setPreventUpdate(bool $preventUpdate)
+ {
+ if ($this->preventUpdate !== $preventUpdate) {
+ $this->preventUpdate = $preventUpdate;
+ $this->markFieldUpdated('preventUpdate');
+ }
+ }
+
+ /**
+ * @param string $title
+ */
+ public function setTitle(string $title)
+ {
+ if ($this->title !== $title) {
+ $this->title = $title;
+ $this->markFieldUpdated('title');
+ }
+ }
+
+ /**
+ * @param int $unreadCount
+ */
+ public function setUnreadCount(int $unreadCount)
+ {
+ if ($this->unreadCount !== $unreadCount) {
+ $this->unreadCount = $unreadCount;
+ $this->markFieldUpdated('unreadCount');
+ }
+ }
+
+ /**
+ * @param int $updateErrorCount
+ */
+ public function setUpdateErrorCount(int $updateErrorCount)
+ {
+ if ($this->updateErrorCount !== $updateErrorCount) {
+ $this->updateErrorCount = $updateErrorCount;
+ $this->markFieldUpdated('updateErrorCount');
+ }
+ }
+
+ /**
+ * @param int $updateMode
+ */
+ public function setUpdateMode(int $updateMode)
+ {
+ if ($this->updateMode !== $updateMode) {
+ $this->updateMode = $updateMode;
+ $this->markFieldUpdated('updateMode');
+ }
+ }
+
+ /**
+ * @param string $url
+ */
+ public function setUrl(string $url)
{
$url = trim($url);
- if(strpos($url, 'http') === 0) {
- parent::setLink($url);
+ if (strpos($url, 'http') === 0 && $this->url !== $url) {
+ $this->url = $url;
+ $this->setUrlHash(md5($url));
+ $this->markFieldUpdated('url');
}
}
+ /**
+ * @param string $urlHash
+ */
+ public function setUrlHash(string $urlHash)
+ {
+ if ($this->urlHash !== $urlHash) {
+ $this->urlHash = $urlHash;
+ $this->markFieldUpdated('urlHash');
+ }
+ }
+
+ /**
+ * @param string $userId
+ */
+ public function setUserId(string $userId)
+ {
+ if ($this->userId !== $userId) {
+ $this->userId = $userId;
+ $this->markFieldUpdated('userId');
+ }
+ }
+ public function toAPI(): array
+ {
+ return $this->serializeFields(
+ [
+ 'id',
+ 'url',
+ 'title',
+ 'faviconLink',
+ 'added',
+ 'folderId',
+ 'unreadCount',
+ 'ordering',
+ 'link',
+ 'pinned',
+ 'updateErrorCount',
+ 'lastUpdateError'
+ ]
+ );
+ }
}