summaryrefslogtreecommitdiffstats
path: root/db/folder.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/folder.php
parent160a0dfebaeb21cc75d7166dfbac6d0ef1a51460 (diff)
add JsonSerializable to entities
Diffstat (limited to 'db/folder.php')
-rw-r--r--db/folder.php35
1 files changed, 25 insertions, 10 deletions
diff --git a/db/folder.php b/db/folder.php
index ed536e18c..d5f50685f 100644
--- a/db/folder.php
+++ b/db/folder.php
@@ -29,13 +29,15 @@ use \OCP\AppFramework\Db\Entity;
* @method integer getDeletedAt()
* @method void setDeletedAt(integer $value)
*/
-class Folder extends Entity implements IAPI {
+class Folder extends Entity implements IAPI, \JsonSerializable {
- public $parentId;
- public $name;
- public $userId;
- public $opened;
- public $deletedAt;
+ use EntityJSONSerializer;
+
+ protected $parentId;
+ protected $name;
+ protected $userId;
+ protected $opened;
+ protected $deletedAt;
public function __construct(){
$this->addType('parentId', 'integer');
@@ -43,11 +45,24 @@ class Folder extends Entity implements IAPI {
$this->addType('deletedAt', 'integer');
}
+ /**
+ * Turns entitie attributes into an array
+ */
+ public function jsonSerialize() {
+ return $this->serializeFields([
+ 'id',
+ 'parentId',
+ 'name',
+ 'userId',
+ 'opened',
+ 'deletedAt',
+ ]);
+ }
public function toAPI() {
- return [
- 'id' => $this->getId(),
- 'name' => $this->getName()
- ];
+ return $this->serializeFields([
+ 'id',
+ 'name'
+ ]);
}
} \ No newline at end of file