addType('folderId', 'integer'); $this->addType('parentId', 'integer'); $this->addType('owner', 'string'); $this->addType('type', 'integer'); $this->addType('participant', 'string'); $this->addType('canWrite', 'boolean'); $this->addType('canShare', 'boolean'); $this->addType('createdAt', 'integer'); } /** * @return array * * @psalm-return array{id: mixed, folderId: mixed, owner: mixed, participant: mixed, type: mixed, canWrite: mixed, canShare: mixed, createdAt: mixed} */ public function toArray(): array { return [ 'id' => $this->id, 'folderId' => $this->folderId, 'owner' => $this->owner, 'participant' => $this->participant, 'type' => $this->type, 'canWrite' => $this->canWrite, 'canShare' => $this->canShare, 'createdAt' => $this->createdAt, 'participantDisplayName' => self::getParticipantDisplayName($this->type, $this->participant), ]; } private static function getParticipantDisplayName($type, $participant) { try { if ($type === IShare::TYPE_USER) { return \OCP\Server::get(IUserManager::class)->get($participant)->getDisplayName(); } if ($type === IShare::TYPE_GROUP) { return \OCP\Server::get(IGroupManager::class)->get($participant)->getDisplayName(); } if ($type === IShare::TYPE_CIRCLE) { return \OCP\Server::get(CirclesService::class)->getCircle($participant)->getName(); } } catch (NotFoundExceptionInterface|ContainerExceptionInterface $e) { return $participant; } } }