Skip to content

Commit 5471772

Browse files
committed
feat(files_external settings): convert to delegated settings
Signed-off-by: Tatjana Kaschperko Lindt <kaschperko-lindt@strato.de>
1 parent 44175e3 commit 5471772

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

apps/files_external/lib/Settings/Admin.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
use OCP\AppFramework\Services\IInitialState;
1515
use OCP\Encryption\IManager;
1616
use OCP\IURLGenerator;
17-
use OCP\Settings\ISettings;
17+
use OCP\IL10N;
18+
use OCP\Settings\IDelegatedSettings;
1819

19-
class Admin implements ISettings {
20+
class Admin implements IDelegatedSettings {
2021
use CommonSettingsTrait;
2122

2223
public function __construct(
@@ -26,6 +27,7 @@ public function __construct(
2627
private GlobalAuth $globalAuth,
2728
private IInitialState $initialState,
2829
private IURLGenerator $urlGenerator,
30+
private IL10N $l10n,
2931
) {
3032
$this->visibility = BackendService::VISIBILITY_ADMIN;
3133
}
@@ -65,4 +67,12 @@ public function getSection() {
6567
public function getPriority() {
6668
return 40;
6769
}
70+
71+
public function getName(): string {
72+
return $this->l10n->t('External storage');
73+
}
74+
75+
public function getAuthorizedAppConfig(): array {
76+
return [];
77+
}
6878
}

apps/files_external/tests/Settings/AdminTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
use OCA\Files_External\Service\BackendService;
1313
use OCA\Files_External\Service\GlobalStoragesService;
1414
use OCA\Files_External\Settings\Admin;
15-
use OCP\App\IAppManager;
1615
use OCP\AppFramework\Http\TemplateResponse;
1716
use OCP\AppFramework\Services\IInitialState;
1817
use OCP\Encryption\IManager;
18+
use OCP\IL10N;
1919
use OCP\IURLGenerator;
2020
use PHPUnit\Framework\MockObject\MockObject;
2121
use Test\TestCase;
@@ -27,7 +27,7 @@ class AdminTest extends TestCase {
2727
private GlobalAuth&MockObject $globalAuth;
2828
private IInitialState&MockObject $initialState;
2929
private IURLGenerator&MockObject $urlGenerator;
30-
private IAppManager&MockObject $appManager;
30+
private IL10N&MockObject $l10n;
3131
private Admin $admin;
3232

3333
protected function setUp(): void {
@@ -38,7 +38,10 @@ protected function setUp(): void {
3838
$this->globalAuth = $this->createMock(GlobalAuth::class);
3939
$this->initialState = $this->createMock(IInitialState::class);
4040
$this->urlGenerator = $this->createMock(IURLGenerator::class);
41-
$this->appManager = $this->createMock(IAppManager::class);
41+
$this->l10n = $this->createMock(IL10N::class);
42+
$this->l10n->method('t')->willReturnCallback(function ($text) {
43+
return $text;
44+
});
4245

4346
$this->admin = new Admin(
4447
$this->encryptionManager,
@@ -47,7 +50,7 @@ protected function setUp(): void {
4750
$this->globalAuth,
4851
$this->initialState,
4952
$this->urlGenerator,
50-
$this->appManager,
53+
$this->l10n,
5154
);
5255
}
5356

0 commit comments

Comments
 (0)