mirror of
https://github.com/verdigado/organization_folders.git
synced 2024-12-06 11:22:41 +01:00
split principal types into different subclasses, added principal factory, implemented principal friendlyNames and FullHierarchyNames, added parentOrganizationId attribute to organizations
This commit is contained in:
parent
225072bff7
commit
89ff5415dd
15 changed files with 321 additions and 47 deletions
|
@ -4,26 +4,30 @@ namespace OCA\OrganizationFolders\Model;
|
|||
|
||||
use OCA\OrganizationFolders\Enum\PrincipalType;
|
||||
|
||||
class Principal implements \JsonSerializable {
|
||||
public function __construct(
|
||||
private PrincipalType $type,
|
||||
private string $id,
|
||||
) {
|
||||
// check if id fits format
|
||||
}
|
||||
abstract class Principal implements \JsonSerializable {
|
||||
protected bool $valid;
|
||||
|
||||
public function getType(): PrincipalType {
|
||||
return $this->type;
|
||||
}
|
||||
abstract public function getType(): PrincipalType;
|
||||
|
||||
public function getId(): string {
|
||||
return $this->id;
|
||||
abstract public function getId(): string;
|
||||
|
||||
abstract public function getFriendlyName(): string;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @psalm-return string[]
|
||||
*/
|
||||
public function getFullHierarchyNames(): array {
|
||||
return [$this->getFriendlyName()];
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'type' => $this->type->value,
|
||||
'id' => $this->id,
|
||||
'type' => $this->getType(),
|
||||
'id' => $this->getId(),
|
||||
'valid' => $this->valid,
|
||||
'friendlyName' => $this->getFriendlyName(),
|
||||
'fullHierarchyNames' => $this->getFullHierarchyNames(),
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue