summaryrefslogtreecommitdiffstats
path: root/db/item.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/item.php
parent160a0dfebaeb21cc75d7166dfbac6d0ef1a51460 (diff)
add JsonSerializable to entities
Diffstat (limited to 'db/item.php')
-rw-r--r--db/item.php51
1 files changed, 36 insertions, 15 deletions
diff --git a/db/item.php b/db/item.php
index 3b18cbc8e..e7cbb7793 100644
--- a/db/item.php
+++ b/db/item.php
@@ -44,21 +44,22 @@ use \OCP\AppFramework\Db\Entity;
* @method integer getLastModified()
* @method void setLastModified(integer $value)
*/
-class Item extends Entity implements IAPI {
-
- public $guidHash;
- public $guid;
- public $url;
- public $title;
- public $author;
- public $pubDate;
- public $body;
- public $enclosureMime;
- public $enclosureLink;
- public $feedId;
- public $status = 0;
- public $lastModified;
-
+class Item extends Entity implements IAPI, \JsonSerializable {
+
+ use EntityJSONSerializer;
+
+ protected $guidHash;
+ protected $guid;
+ protected $url;
+ protected $title;
+ protected $author;
+ protected $pubDate;
+ protected $body;
+ protected $enclosureMime;
+ protected $enclosureLink;
+ protected $feedId;
+ protected $status = 0;
+ protected $lastModified;
public function __construct(){
$this->addType('pubDate', 'integer');
@@ -104,6 +105,26 @@ class Item extends Entity implements IAPI {
return !$this->isStarred();
}
+ /**
+ * Turns entitie attributes into an array
+ */
+ public function jsonSerialize() {
+ return $this->serializeFields([
+ 'id',
+ 'guidHash',
+ 'guid',
+ 'url',
+ 'title',
+ 'author',
+ 'pubDate',
+ 'body',
+ 'enclosureMime',
+ 'enclosureLink',
+ 'feedId',
+ 'status',
+ 'lastModified',
+ ]);
+ }
public function toAPI() {
return [