summaryrefslogtreecommitdiffstats
path: root/db/feed.php
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-14 17:49:52 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-14 17:49:52 +0200
commitf52cdaa750f1efa8cb76f6d88c9b1dc291f7b328 (patch)
treea2d6c7b403ea08cef061f0d599a51103f14ff9be /db/feed.php
parent160a0dfebaeb21cc75d7166dfbac6d0ef1a51460 (diff)
add JsonSerializable to entities
Diffstat (limited to 'db/feed.php')
-rw-r--r--db/feed.php69
1 files changed, 46 insertions, 23 deletions
diff --git a/db/feed.php b/db/feed.php
index 30bcbf865..4f1e0979e 100644
--- a/db/feed.php
+++ b/db/feed.php
@@ -43,20 +43,22 @@ use \OCP\AppFramework\Db\Entity;
* @method integer getArticlesPerUpdate()
* @method void setArticlesPerUpdate(integer $value)
*/
-class Feed extends Entity implements IAPI {
+class Feed extends Entity implements IAPI, \JsonSerializable {
- public $userId;
- public $urlHash;
- public $url;
- public $title;
- public $faviconLink;
- public $added;
- public $folderId;
- public $unreadCount;
- public $link;
- public $preventUpdate;
- public $deletedAt;
- public $articlesPerUpdate;
+ use EntityJSONSerializer;
+
+ protected $userId;
+ protected $urlHash;
+ protected $url;
+ protected $title;
+ protected $faviconLink;
+ protected $added;
+ protected $folderId;
+ protected $unreadCount;
+ protected $link;
+ protected $preventUpdate;
+ protected $deletedAt;
+ protected $articlesPerUpdate;
public function __construct(){
$this->addType('parentId', 'integer');
@@ -69,17 +71,38 @@ class Feed extends Entity implements IAPI {
}
+ /**
+ * Turns entitie attributes into an array
+ */
+ public function jsonSerialize() {
+ return $this->serializeFields([
+ 'id',
+ 'userId',
+ 'urlHash',
+ 'url',
+ 'title',
+ 'faviconLink',
+ 'added',
+ 'folderId',
+ 'unreadCount',
+ 'link',
+ 'preventUpdate',
+ 'deletedAt',
+ 'articlesPerUpdate',
+ ]);
+ }
+
public function toAPI() {
- return [
- 'id' => $this->getId(),
- 'url' => $this->getUrl(),
- 'title' => $this->getTitle(),
- 'faviconLink' => $this->getFaviconLink(),
- 'added' => $this->getAdded(),
- 'folderId' => $this->getFolderId(),
- 'unreadCount' => $this->getUnreadCount(),
- 'link' => $this->getLink()
- ];
+ return $this->serializeFields([
+ 'id',
+ 'url',
+ 'title',
+ 'faviconLink',
+ 'added',
+ 'folderId',
+ 'unreadCount',
+ 'link'
+ ]);
}