From 329e8c2604a35bded6afac75b59f611002d6db5e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julius=20H=C3=A4rtl?= <jus@bitgrid.net>
Date: Tue, 26 Nov 2019 13:07:15 +0100
Subject: [PATCH] Add mimetype to creators
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Julius Härtl <jus@bitgrid.net>
---
 apps/files/lib/Capabilities.php           | 7 ++-----
 lib/public/DirectEditing/ACreateEmpty.php | 8 ++++++++
 tests/lib/DirectEditing/ManagerTest.php   | 4 ++++
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/apps/files/lib/Capabilities.php b/apps/files/lib/Capabilities.php
index 19b59971c4c..270c6954a1a 100644
--- a/apps/files/lib/Capabilities.php
+++ b/apps/files/lib/Capabilities.php
@@ -102,12 +102,9 @@ class Capabilities implements ICapability {
 					'id' => $id,
 					'name' => $creator->getName(),
 					'extension' => $creator->getExtension(),
-					'templates' => false
+					'templates' => $creator instanceof ACreateFromTemplate,
+					'mimetype' => $creator->getMimetype()
 				];
-				if ($creator instanceof ACreateFromTemplate) {
-					$capabilities['creators'][$id]['templates'] = true;
-				}
-
 			}
 		}
 		return $capabilities;
diff --git a/lib/public/DirectEditing/ACreateEmpty.php b/lib/public/DirectEditing/ACreateEmpty.php
index 79684e33b80..ab7f7fd3ae8 100644
--- a/lib/public/DirectEditing/ACreateEmpty.php
+++ b/lib/public/DirectEditing/ACreateEmpty.php
@@ -59,6 +59,14 @@ abstract class ACreateEmpty {
 	 */
 	abstract public function getExtension(): string;
 
+	/**
+	 * Mimetype of the resulting created file
+	 *
+	 * @since 18.0.0
+	 * @return string
+	 */
+	abstract public function getMimetype(): string;
+
 	/**
 	 * Add content when creating empty files
 	 *
diff --git a/tests/lib/DirectEditing/ManagerTest.php b/tests/lib/DirectEditing/ManagerTest.php
index a3d29efbce5..9a56c3307e0 100644
--- a/tests/lib/DirectEditing/ManagerTest.php
+++ b/tests/lib/DirectEditing/ManagerTest.php
@@ -31,6 +31,10 @@ class CreateEmpty extends ACreateEmpty {
 	public function getExtension(): string {
 		return '.txt';
 	}
+
+	 public function getMimetype(): string {
+		return 'text/plain';
+	}
 }
 
 class Editor implements IEditor {
-- 
GitLab