blob: 143d02631ed7ffda7d0d242036b3aa170ce736fc (
plain)
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
|
<?php
namespace OCA\Text\Service;
use OCP\Files\Folder;
use OCP\Files\NotFoundException;
use OCP\IL10N;
class WorkspaceService {
private const SUPPORTED_STATIC_FILENAMES = [
'README.md',
'Readme.md',
'readme.md'
];
/** @var IL10N */
private $l10n;
public function __construct(IL10N $l10n) {
$this->l10n = $l10n;
}
public function getFile(Folder $folder) {
$file = null;
foreach ($this->getSupportedFilenames() as $filename) {
if ($folder->nodeExists($filename)) {
try {
$file = $folder->get($filename);
} catch (NotFoundException $e) {
}
continue;
}
}
return $file;
}
public function getSupportedFilenames() {
return array_merge([
$this->l10n->t('Readme') . '.md'
], self::SUPPORTED_STATIC_FILENAMES);
}
}
|