Skip to content

Commit

Permalink
fix: Create empty files from template if available
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr authored and backportbot-nextcloud[bot] committed Jul 13, 2023
1 parent 2087f0e commit 40582d9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Listener/FileCreatedFromTemplateListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public function handle(Event $event): void {
// Empty template
if ($templateFile === null) {
$event->getTarget()->putContent($this->templateManager->getEmptyFileContent($event->getTarget()->getExtension()));
$templateType = $this->templateManager->getTemplateTypeForExtension($event->getTarget()->getExtension());
$emptyTemplates = $this->templateManager->getEmpty($templateType);
$emptyTemplate = array_shift($emptyTemplates);
if ($emptyTemplate && $this->templateManager->isSupportedTemplateSource($emptyTemplate->getExtension())) {
// Only use TemplateSource if supported filetype
$this->templateManager->setTemplateSource($event->getTarget()->getId(), $emptyTemplate->getId());
}
return;
}

Expand Down

0 comments on commit 40582d9

Please sign in to comment.