children === null) { $albums = $this->albumMapper->getSharedAlbumsForCollaboratorWithFiles($this->userId, AlbumMapper::TYPE_USER); $user = $this->userManager->get($this->userId); $userGroups = $this->groupManager->getUserGroupIds($user); foreach ($userGroups as $groupId) { $albumsForGroup = $this->albumMapper->getSharedAlbumsForCollaboratorWithFiles($groupId, AlbumMapper::TYPE_GROUP); $albumsForGroup = array_udiff($albumsForGroup, $albums, fn ($a, $b): int => $a->getAlbum()->getId() - $b->getAlbum()->getId()); $albums = array_merge($albums, $albumsForGroup); } $this->children = array_map(fn (AlbumWithFiles $album): SharedAlbumRoot => new SharedAlbumRoot( $this->albumMapper, $album, $this->rootFolder, $this->userId, $this->userConfigService, $this->logger, $this->userManager, ), $albums); } return $this->children; } }