0
0
Fork 0
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:
Jonathan Treffler 2024-11-26 18:19:05 +01:00
parent 225072bff7
commit 89ff5415dd
15 changed files with 321 additions and 47 deletions

View file

@ -8,13 +8,44 @@ use OCP\AppFramework\Db\QBMapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCA\OrganizationFolders\Enum\PrincipalType;
use OCA\OrganizationFolders\Model\PrincipalFactory;
class OrganizationFolderMemberMapper extends QBMapper {
public const ORGANIZATIONFOLDER_MEMBERS_TABLE = "organizationfolders_members";
public function __construct(IDBConnection $db) {
public function __construct(
protected PrincipalFactory $principalFactory,
IDBConnection $db,
) {
parent::__construct($db, self::ORGANIZATIONFOLDER_MEMBERS_TABLE, OrganizationFolderMember::class);
}
/**
*
* @param array $row the row which should be converted to an entity
* @return OrganizationFolderMember the entity
* @psalm-return OrganizationFolderMember the entity
*/
protected function mapRowToEntity(array $row): OrganizationFolderMember {
$member = new OrganizationFolderMember();
$member->setId($row["id"]);
$member->setOrganizationFolderId($row["organization_folder_id"]);
$member->setPermissionLevel($row["permission_level"]);
$principalType = PrincipalType::from($row["principal_type"]);
$principal = $this->principalFactory->buildPrincipal($principalType, $row["principal_id"]);
$member->setPrincipal($principal);
$member->setCreatedTimestamp($row["created_timestamp"]);
$member->setLastUpdatedTimestamp($row["last_updated_timestamp"]);
$member->resetUpdatedFields();
return $member;
}
/**
* @param int $id
* @return Entity|OrganizationFolderMember