appName . "_" . $this->format; } /** * Descriptive name for the create action */ public function getName(): string { return match ($this->format) { "xlsx" => $this->trans->t("New spreadsheet"), "pptx" => $this->trans->t("New presentation"), default => $this->trans->t("New document"), }; } /** * Default file extension for the new file */ public function getExtension(): string { return $this->format; } /** * Mimetype of the resulting created file */ public function getMimetype(): string { return match ($this->format) { "xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", default => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", }; } /** * Add content when creating empty files */ public function create(File $file, ?string $creatorId = null, ?string $templateId = null): void { $this->logger->debug("FileCreator: " . $file->getId() . " " . $file->getName() . " $creatorId $templateId"); $fileName = $file->getName(); $template = TemplateManager::getEmptyTemplate($fileName); if (!$template) { $this->logger->error("FileCreator: Template for file creation not found: $templateId"); return; } try { $file->putContent($template); } catch (NotPermittedException $e) { $this->logger->error("FileCreator: Can't create file: $fileName", ["exception" => $e]); } } }