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
36
lib/Model/UserPrincipal.php
Normal file
36
lib/Model/UserPrincipal.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\OrganizationFolders\Model;
|
||||
|
||||
use OCP\IUserManager;
|
||||
use \OCP\IUser;
|
||||
|
||||
use OCA\OrganizationFolders\Enum\PrincipalType;
|
||||
|
||||
class UserPrincipal extends Principal {
|
||||
private ?IUser $user;
|
||||
|
||||
public function __construct(
|
||||
private IUserManager $userManager,
|
||||
private string $id,
|
||||
) {
|
||||
try {
|
||||
$this->user = $this->userManager->get($id);
|
||||
$this->valid = !is_null($this->user);
|
||||
} catch (\Exception $e) {
|
||||
$this->valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getType(): PrincipalType {
|
||||
return PrincipalType::USER;
|
||||
}
|
||||
|
||||
public function getId(): string {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getFriendlyName(): string {
|
||||
return $this->user?->getDisplayName();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue