-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy pathTextDocumentCreator.php
More file actions
53 lines (42 loc) · 1014 Bytes
/
TextDocumentCreator.php
File metadata and controls
53 lines (42 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Text\DirectEditing;
use OCP\DirectEditing\ACreateEmpty;
use OCP\IAppConfig;
use OCP\IL10N;
class TextDocumentCreator extends ACreateEmpty {
public const CREATOR_ID = 'textdocument';
/**
* @var IL10N
*/
private $l10n;
/**
* @var IAppConfig
*/
private $appConfig;
public function __construct(IL10N $l10n, IAppConfig $appConfig) {
$this->l10n = $l10n;
$this->appConfig = $appConfig;
}
public function getId(): string {
return self::CREATOR_ID;
}
public function getName(): string {
return $this->l10n->t('Text document');
}
public function getExtension(): string {
return $this->appConfig->getValueString('text', 'default_file_extension', 'md');
}
public function getMimetype(): string {
switch ($this->getExtension()) {
case 'txt':
return 'text/plain';
case 'md':
default:
return 'text/markdown';
}
}
}