mirror of
https://github.com/verdigado/organization_folders.git
synced 2024-11-22 04:38:09 +01:00
implemented Organization Provider models
This commit is contained in:
parent
0e197d02cb
commit
92cef844d4
5 changed files with 120 additions and 47 deletions
19
lib/Model/Organization.php
Normal file
19
lib/Model/Organization.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\OrganizationFolders\Model;
|
||||
|
||||
class Organization implements \JsonSerializable {
|
||||
public function __construct(
|
||||
private int $id,
|
||||
private string $membersGroup,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getId(): int {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getMembersGroup(): string {
|
||||
return $this->membersGroup;
|
||||
}
|
||||
}
|
29
lib/Model/OrganizationRole.php
Normal file
29
lib/Model/OrganizationRole.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\OrganizationFolders\Model;
|
||||
|
||||
class OrganizationRole implements \JsonSerializable {
|
||||
public function __construct(
|
||||
private int $id,
|
||||
private int $organizationId,
|
||||
private string $friendlyName,
|
||||
private string $membersGroup,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getId(): int {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getOrganizationId(): int {
|
||||
return $this->organizationId;
|
||||
}
|
||||
|
||||
public function getFriendlyName(): string {
|
||||
return $this->friendlyName;
|
||||
}
|
||||
|
||||
public function getMembersGroup(): string {
|
||||
return $this->membersGroup;
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\OrganizationFolders\OrganizationProvider;
|
||||
|
||||
abstract class OrganizationProvider {
|
||||
protected $id;
|
||||
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/* Return one level of the Organization Tree */
|
||||
/*
|
||||
* ┌────────────────────────────┐
|
||||
* │ Root Node │
|
||||
* │ (of Organization Provider) │
|
||||
* └──┬──────────────────────┬──┘
|
||||
* │ │
|
||||
* │ │
|
||||
* ┌── ── ── │── ── ── ── ── ── ── ─│─ ── ── ─┐
|
||||
* │ │
|
||||
* │ ▼ ▼ │
|
||||
* ┌──────────────┐ ┌──────────────┐
|
||||
* │ │ │ │ │ │
|
||||
* │Organization 1│ │Organization 2│ ◄── ── ── getOrganizations();
|
||||
* │ │ │ │ │ │
|
||||
* └┬────────────┬┘ └┬────────────┬┘
|
||||
* │ │ │ │ │ │
|
||||
* │ │ │ │
|
||||
* └── ├─ ── ── ── ─┤ ── ── ─┼ ── ── ── ──│── ┘
|
||||
* │ │ │ │
|
||||
* ▼ ▼ │ │
|
||||
* ... ... ▼ ▼
|
||||
* ┌── ── ── ── ── ── ── ── ── ── ─┐
|
||||
* ┌────────────┐ ┌────────────┐
|
||||
* │ │ │ │ │ │
|
||||
* │ Suborg. 21 │ │ Suborg. 22 │ ◄── ── ── getOrganizations(2);
|
||||
* │ │ │ │ │ │
|
||||
* └────────────┘ └────────────┘
|
||||
* └── ── ── ── ── ── ── ── ── ── ─┘
|
||||
*/
|
||||
abstract public function getOrganizations(?int $parentOrganizationId);
|
||||
|
||||
abstract public function getRolesOfOrganization(int $organizationId);
|
||||
}
|
72
lib/OrganisationProvider/OrganizationProvider.php
Normal file
72
lib/OrganisationProvider/OrganizationProvider.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\OrganizationFolders\OrganizationProvider;
|
||||
|
||||
use OCA\OrganizationFolders\Model\Organization;
|
||||
use OCA\OrganizationFolders\Model\OrganizationRole;
|
||||
|
||||
abstract class OrganizationProvider {
|
||||
protected $id;
|
||||
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific role by its id (unique within OrganizationProvider)
|
||||
* @return Organization
|
||||
*/
|
||||
abstract public function getOrganization(int $id): Organization;
|
||||
|
||||
/**
|
||||
* Return one level of the Organization Tree
|
||||
*
|
||||
* ┌────────────────────────────┐
|
||||
* │ Root Node │
|
||||
* │ (of Organization Provider) │
|
||||
* └──┬──────────────────────┬──┘
|
||||
* │ │
|
||||
* │ │
|
||||
* ┌── ── ── │── ── ── ── ── ── ── ─│─ ── ── ─┐
|
||||
* │ │
|
||||
* │ ▼ ▼ │
|
||||
* ┌──────────────┐ ┌──────────────┐
|
||||
* │ │ │ │ │ │
|
||||
* │Organization 1│ │Organization 2│ ◄── ── ── getSubOrganizations();
|
||||
* │ │ │ │ │ │
|
||||
* └┬────────────┬┘ └┬────────────┬┘
|
||||
* │ │ │ │ │ │
|
||||
* │ │ │ │
|
||||
* └── ├─ ── ── ── ─┤ ── ── ─┼ ── ── ── ──│── ┘
|
||||
* │ │ │ │
|
||||
* ▼ ▼ │ │
|
||||
* ... ... ▼ ▼
|
||||
* ┌── ── ── ── ── ── ── ── ── ── ─┐
|
||||
* ┌────────────┐ ┌────────────┐
|
||||
* │ │ │ │ │ │
|
||||
* │ Suborg. 21 │ │ Suborg. 22 │ ◄── ── ── getSubOrganizations(2);
|
||||
* │ │ │ │ │ │
|
||||
* └────────────┘ └────────────┘
|
||||
* └── ── ── ── ── ── ── ── ── ── ─┘
|
||||
*
|
||||
* @return Organization[]
|
||||
*/
|
||||
abstract public function getSubOrganizations(?int $parentOrganizationId): array;
|
||||
|
||||
/**
|
||||
* Get specific role by its id (unique within OrganizationProvider)
|
||||
*
|
||||
* @return OrganizationRole
|
||||
*/
|
||||
abstract public function getRole(int $id): OrganizationRole;
|
||||
|
||||
/**
|
||||
* Get all roles of a specific organization
|
||||
*
|
||||
* @return OrganizationRole[]
|
||||
*/
|
||||
abstract public function getRolesOfOrganization(int $organizationId): array;
|
||||
|
||||
}
|
Loading…
Reference in a new issue