mirror of
https://github.com/verdigado/organization_folders.git
synced 2024-11-24 21:50:26 +01:00
added resource entities
This commit is contained in:
parent
d558c1dd82
commit
8064b75093
2 changed files with 72 additions and 0 deletions
50
lib/Db/FolderResource.php
Normal file
50
lib/Db/FolderResource.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\OrganizationFolders\Db;
|
||||
|
||||
class FolderResource extends Resource {
|
||||
protected $membersAclPermission;
|
||||
protected $managersAclPermission;
|
||||
protected $inheritedAclPermission;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->addType('membersAclPermission','integer');
|
||||
$this->addType('managersAclPermission','integer');
|
||||
$this->addType('inheritedAclPermission','integer');
|
||||
}
|
||||
|
||||
public static function fromRow(array $row): static {
|
||||
$instance = new static();
|
||||
|
||||
$instance->setId($row["id"]);
|
||||
$instance->setParentResource($row["parent_resource"]);
|
||||
$instance->setGroupFolderId($row["group_folder_id"]);
|
||||
$instance->setName($row["name"]);
|
||||
$instance->setActive($row["active"]);
|
||||
$instance->setLastUpdatedTimestamp($row["last_updated_timestamp"]);
|
||||
$instance->setMembersAclPermission($row["members_acl_permission"]);
|
||||
$instance->setManagersAclPermission($row["managers_acl_permission"]);
|
||||
$instance->setInheritedAclPermission($row["inherited_acl_permission"]);
|
||||
|
||||
$instance->resetUpdatedFields();
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'parentResource' => $this->parentResource,
|
||||
'groupFolderId' => $this->groupFolderId,
|
||||
'type' => "folder",
|
||||
'name' => $this->name,
|
||||
'active' => $this->active,
|
||||
'lastUpdatedTimestamp' => $this->lastUpdatedTimestamp,
|
||||
|
||||
'membersAclPermission' => $this->membersAclPermission,
|
||||
'managersAclPermission' => $this->managersAclPermission,
|
||||
'inheritedAclPermission' => $this->inheritedAclPermission,
|
||||
];
|
||||
}
|
||||
}
|
22
lib/Db/Resource.php
Normal file
22
lib/Db/Resource.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\OrganizationFolders\Db;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
|
||||
abstract class Resource extends Entity implements JsonSerializable {
|
||||
protected $groupFolderId;
|
||||
protected $parentResource;
|
||||
protected $name;
|
||||
protected $active;
|
||||
protected $lastUpdatedTimestamp;
|
||||
|
||||
public function __construct() {
|
||||
$this->addType('groupFolderId','integer');
|
||||
$this->addType('parentResource','integer');
|
||||
$this->addType('active','bool');
|
||||
$this->addType('lastUpdatedTimestamp','integer');
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue