isSameUserTemplateFolder() ? $this->templateManager->getSystem($type) : $this->templateManager->getAll($type); return array_map(function (File $file) { $template = new Template(CollaboraTemplateProvider::class, (string)$file->getId(), $file); $template->setCustomPreviewUrl($this->urlGenerator->linkToRouteAbsolute('richdocuments.templates.getPreview', ['fileId' => $file->getId(), 'a' => true])); return $template; }, $collaboraTemplates); } private function isSameUserTemplateFolder(): bool { try { $userTemplatesFolder = $this->templateManager->getUserTemplateDir(); $internalPath = $userTemplatesFolder->getInternalPath(); $userTemplatePath = mb_strpos($internalPath, 'files/') === 0 ? mb_substr($internalPath, 5): $internalPath; return $this->coreTemplateManager->getTemplatePath() === $userTemplatePath; } catch (NotFoundException) { } return false; } public function getCustomTemplate(string $template): File { return $this->templateManager->get((int)$template); } }