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
juliushaertl committed Jul 11, 2023
1 parent ebab08b commit 45973ce
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 45973ce

Please sign in to comment.