mirror of
https://github.com/nextcloud/server.git
synced 2026-02-27 03:50:37 -05:00
Merge pull request #47862 from nextcloud/backport/47860/stable29
This commit is contained in:
commit
408c870f61
1 changed files with 1 additions and 3 deletions
|
|
@ -159,11 +159,9 @@ class TemplateManager implements ITemplateManager {
|
|||
throw new GenericFileException($this->l10n->t('Invalid path'));
|
||||
}
|
||||
$folder = $userFolder->get(dirname($filePath));
|
||||
$targetFile = $folder->newFile(basename($filePath));
|
||||
$template = null;
|
||||
if ($templateType === 'user' && $templateId !== '') {
|
||||
$template = $userFolder->get($templateId);
|
||||
$template->copy($targetFile->getPath());
|
||||
} else {
|
||||
$matchingProvider = array_filter($this->getRegisteredProviders(), function (ICustomTemplateProvider $provider) use ($templateType) {
|
||||
return $templateType === get_class($provider);
|
||||
|
|
@ -171,9 +169,9 @@ class TemplateManager implements ITemplateManager {
|
|||
$provider = array_shift($matchingProvider);
|
||||
if ($provider) {
|
||||
$template = $provider->getCustomTemplate($templateId);
|
||||
$template->copy($targetFile->getPath());
|
||||
}
|
||||
}
|
||||
$targetFile = $folder->newFile(basename($filePath), ($template instanceof File ? $template->fopen('rb') : null));
|
||||
$this->eventDispatcher->dispatchTyped(new FileCreatedFromTemplateEvent($template, $targetFile));
|
||||
return $this->formatFile($userFolder->get($filePath));
|
||||
} catch (\Exception $e) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue