diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-01-31 16:55:17 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-01-31 16:55:17 +0100 |
commit | bfaf3fff33b663dd3e90f825445d1c95c98ea724 (patch) | |
tree | 5c25cb51be7e7fdbae01ef8a857654f724ea4695 | |
parent | 78c7e6f2c5609122d047a36fc44390b42a341566 (diff) | |
download | nextcloud-server-bfaf3fff33b663dd3e90f825445d1c95c98ea724.tar.gz nextcloud-server-bfaf3fff33b663dd3e90f825445d1c95c98ea724.zip |
Move Admin Settings also to info.xml
More cleanup of the Settings apps. Makes the manager cleaner and a
proper manager.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r-- | apps/settings/appinfo/info.xml | 5 | ||||
-rw-r--r-- | apps/settings/composer/composer/autoload_classmap.php | 10 | ||||
-rw-r--r-- | apps/settings/composer/composer/autoload_static.php | 10 | ||||
-rw-r--r-- | apps/settings/lib/Settings/Admin/Mail.php | 2 | ||||
-rw-r--r-- | apps/settings/lib/Settings/Admin/Overview.php | 2 | ||||
-rw-r--r-- | apps/settings/lib/Settings/Admin/Security.php | 2 | ||||
-rw-r--r-- | apps/settings/lib/Settings/Admin/Server.php | 2 | ||||
-rw-r--r-- | apps/settings/lib/Settings/Admin/Sharing.php | 2 | ||||
-rw-r--r-- | apps/settings/tests/Settings/Admin/MailTest.php | 2 | ||||
-rw-r--r-- | apps/settings/tests/Settings/Admin/SecurityTest.php | 2 | ||||
-rw-r--r-- | apps/settings/tests/Settings/Admin/ServerTest.php | 2 | ||||
-rw-r--r-- | apps/settings/tests/Settings/Admin/SharingTest.php | 2 | ||||
-rw-r--r-- | lib/private/Settings/Manager.php | 48 | ||||
-rw-r--r-- | tests/lib/Settings/ManagerTest.php | 33 |
14 files changed, 45 insertions, 79 deletions
diff --git a/apps/settings/appinfo/info.xml b/apps/settings/appinfo/info.xml index f2325c3afca..2513b9a20fa 100644 --- a/apps/settings/appinfo/info.xml +++ b/apps/settings/appinfo/info.xml @@ -18,6 +18,11 @@ </dependencies> <settings> + <admin>OCA\Settings\Settings\Admin\Mail</admin> + <admin>OCA\Settings\Settings\Admin\Overview</admin> + <admin>OCA\Settings\Settomgs\Admin\Security</admin> + <admin>OCA\Settings\Settings\Admin\Server</admin> + <admin>OCA\Settings\Settings\Admin\Sharing</admin> <admin-section>OCA\Settings\Sections\Admin\Additional</admin-section> <admin-section>OCA\Settings\Sections\Admin\Groupware</admin-section> <admin-section>OCA\Settings\Sections\Admin\Overview</admin-section> diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index c68f3d85279..841a1aa21eb 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -13,11 +13,6 @@ return array( 'OCA\\Settings\\Activity\\SecurityProvider' => $baseDir . '/../lib/Activity/SecurityProvider.php', 'OCA\\Settings\\Activity\\SecuritySetting' => $baseDir . '/../lib/Activity/SecuritySetting.php', 'OCA\\Settings\\Activity\\Setting' => $baseDir . '/../lib/Activity/Setting.php', - 'OCA\\Settings\\Admin\\Mail' => $baseDir . '/../lib/Settings/Admin/Mail.php', - 'OCA\\Settings\\Admin\\Overview' => $baseDir . '/../lib/Settings/Admin/Overview.php', - 'OCA\\Settings\\Admin\\Security' => $baseDir . '/../lib/Settings/Admin/Security.php', - 'OCA\\Settings\\Admin\\Server' => $baseDir . '/../lib/Settings/Admin/Server.php', - 'OCA\\Settings\\Admin\\Sharing' => $baseDir . '/../lib/Settings/Admin/Sharing.php', 'OCA\\Settings\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', 'OCA\\Settings\\BackgroundJobs\\VerifyUserData' => $baseDir . '/../lib/BackgroundJobs/VerifyUserData.php', 'OCA\\Settings\\Controller\\AdminSettingsController' => $baseDir . '/../lib/Controller/AdminSettingsController.php', @@ -45,6 +40,11 @@ return array( 'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => $baseDir . '/../lib/Sections/Personal/PersonalInfo.php', 'OCA\\Settings\\Sections\\Personal\\Security' => $baseDir . '/../lib/Sections/Personal/Security.php', 'OCA\\Settings\\Sections\\Personal\\SyncClients' => $baseDir . '/../lib/Sections/Personal/SyncClients.php', + 'OCA\\Settings\\Settings\\Admin\\Mail' => $baseDir . '/../lib/Settings/Admin/Mail.php', + 'OCA\\Settings\\Settings\\Admin\\Overview' => $baseDir . '/../lib/Settings/Admin/Overview.php', + 'OCA\\Settings\\Settings\\Admin\\Security' => $baseDir . '/../lib/Settings/Admin/Security.php', + 'OCA\\Settings\\Settings\\Admin\\Server' => $baseDir . '/../lib/Settings/Admin/Server.php', + 'OCA\\Settings\\Settings\\Admin\\Sharing' => $baseDir . '/../lib/Settings/Admin/Sharing.php', 'OCA\\Settings\\Settings\\Personal\\Additional' => $baseDir . '/../lib/Settings/Personal/Additional.php', 'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => $baseDir . '/../lib/Settings/Personal/PersonalInfo.php', 'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => $baseDir . '/../lib/Settings/Personal/Security/Authtokens.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index 41b2ad27271..bac850545f3 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -28,11 +28,6 @@ class ComposerStaticInitSettings 'OCA\\Settings\\Activity\\SecurityProvider' => __DIR__ . '/..' . '/../lib/Activity/SecurityProvider.php', 'OCA\\Settings\\Activity\\SecuritySetting' => __DIR__ . '/..' . '/../lib/Activity/SecuritySetting.php', 'OCA\\Settings\\Activity\\Setting' => __DIR__ . '/..' . '/../lib/Activity/Setting.php', - 'OCA\\Settings\\Admin\\Mail' => __DIR__ . '/..' . '/../lib/Settings/Admin/Mail.php', - 'OCA\\Settings\\Admin\\Overview' => __DIR__ . '/..' . '/../lib/Settings/Admin/Overview.php', - 'OCA\\Settings\\Admin\\Security' => __DIR__ . '/..' . '/../lib/Settings/Admin/Security.php', - 'OCA\\Settings\\Admin\\Server' => __DIR__ . '/..' . '/../lib/Settings/Admin/Server.php', - 'OCA\\Settings\\Admin\\Sharing' => __DIR__ . '/..' . '/../lib/Settings/Admin/Sharing.php', 'OCA\\Settings\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', 'OCA\\Settings\\BackgroundJobs\\VerifyUserData' => __DIR__ . '/..' . '/../lib/BackgroundJobs/VerifyUserData.php', 'OCA\\Settings\\Controller\\AdminSettingsController' => __DIR__ . '/..' . '/../lib/Controller/AdminSettingsController.php', @@ -60,6 +55,11 @@ class ComposerStaticInitSettings 'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Sections/Personal/PersonalInfo.php', 'OCA\\Settings\\Sections\\Personal\\Security' => __DIR__ . '/..' . '/../lib/Sections/Personal/Security.php', 'OCA\\Settings\\Sections\\Personal\\SyncClients' => __DIR__ . '/..' . '/../lib/Sections/Personal/SyncClients.php', + 'OCA\\Settings\\Settings\\Admin\\Mail' => __DIR__ . '/..' . '/../lib/Settings/Admin/Mail.php', + 'OCA\\Settings\\Settings\\Admin\\Overview' => __DIR__ . '/..' . '/../lib/Settings/Admin/Overview.php', + 'OCA\\Settings\\Settings\\Admin\\Security' => __DIR__ . '/..' . '/../lib/Settings/Admin/Security.php', + 'OCA\\Settings\\Settings\\Admin\\Server' => __DIR__ . '/..' . '/../lib/Settings/Admin/Server.php', + 'OCA\\Settings\\Settings\\Admin\\Sharing' => __DIR__ . '/..' . '/../lib/Settings/Admin/Sharing.php', 'OCA\\Settings\\Settings\\Personal\\Additional' => __DIR__ . '/..' . '/../lib/Settings/Personal/Additional.php', 'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Settings/Personal/PersonalInfo.php', 'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Authtokens.php', diff --git a/apps/settings/lib/Settings/Admin/Mail.php b/apps/settings/lib/Settings/Admin/Mail.php index 387fb5f475b..4ad22cbc216 100644 --- a/apps/settings/lib/Settings/Admin/Mail.php +++ b/apps/settings/lib/Settings/Admin/Mail.php @@ -27,7 +27,7 @@ * */ -namespace OCA\Settings\Admin; +namespace OCA\Settings\Settings\Admin; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; diff --git a/apps/settings/lib/Settings/Admin/Overview.php b/apps/settings/lib/Settings/Admin/Overview.php index 4fd9d673c5b..3399a425ee8 100644 --- a/apps/settings/lib/Settings/Admin/Overview.php +++ b/apps/settings/lib/Settings/Admin/Overview.php @@ -23,7 +23,7 @@ * */ -namespace OCA\Settings\Admin; +namespace OCA\Settings\Settings\Admin; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; diff --git a/apps/settings/lib/Settings/Admin/Security.php b/apps/settings/lib/Settings/Admin/Security.php index 8a804f054fc..e5e00928faa 100644 --- a/apps/settings/lib/Settings/Admin/Security.php +++ b/apps/settings/lib/Settings/Admin/Security.php @@ -25,7 +25,7 @@ * */ -namespace OCA\Settings\Admin; +namespace OCA\Settings\Settings\Admin; use OC\Authentication\TwoFactorAuth\MandatoryTwoFactor; use OCP\AppFramework\Http\TemplateResponse; diff --git a/apps/settings/lib/Settings/Admin/Server.php b/apps/settings/lib/Settings/Admin/Server.php index 543e7dbc592..6216af4aada 100644 --- a/apps/settings/lib/Settings/Admin/Server.php +++ b/apps/settings/lib/Settings/Admin/Server.php @@ -25,7 +25,7 @@ * */ -namespace OCA\Settings\Admin; +namespace OCA\Settings\Settings\Admin; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; diff --git a/apps/settings/lib/Settings/Admin/Sharing.php b/apps/settings/lib/Settings/Admin/Sharing.php index 591d6a64b8b..c151e7be4e1 100644 --- a/apps/settings/lib/Settings/Admin/Sharing.php +++ b/apps/settings/lib/Settings/Admin/Sharing.php @@ -27,7 +27,7 @@ * */ -namespace OCA\Settings\Admin; +namespace OCA\Settings\Settings\Admin; use OC\Share\Share; use OCP\AppFramework\Http\TemplateResponse; diff --git a/apps/settings/tests/Settings/Admin/MailTest.php b/apps/settings/tests/Settings/Admin/MailTest.php index fba08413398..adb7e2fdbd6 100644 --- a/apps/settings/tests/Settings/Admin/MailTest.php +++ b/apps/settings/tests/Settings/Admin/MailTest.php @@ -29,7 +29,7 @@ namespace OCA\Settings\Tests\Settings\Admin; -use OCA\Settings\Admin\Mail; +use OCA\Settings\Settings\Admin\Mail; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; use Test\TestCase; diff --git a/apps/settings/tests/Settings/Admin/SecurityTest.php b/apps/settings/tests/Settings/Admin/SecurityTest.php index 69941594c15..a8a140b2c5d 100644 --- a/apps/settings/tests/Settings/Admin/SecurityTest.php +++ b/apps/settings/tests/Settings/Admin/SecurityTest.php @@ -30,7 +30,7 @@ namespace OCA\Settings\Tests\Settings\Admin; use OC\Authentication\TwoFactorAuth\MandatoryTwoFactor; use OC\Encryption\Manager; -use OCA\Settings\Admin\Security; +use OCA\Settings\Settings\Admin\Security; use OCP\AppFramework\Http\TemplateResponse; use OCP\IInitialStateService; use OCP\IUserManager; diff --git a/apps/settings/tests/Settings/Admin/ServerTest.php b/apps/settings/tests/Settings/Admin/ServerTest.php index 525e43f7d61..aeb37f8d6cc 100644 --- a/apps/settings/tests/Settings/Admin/ServerTest.php +++ b/apps/settings/tests/Settings/Admin/ServerTest.php @@ -29,7 +29,7 @@ namespace OCA\Settings\Tests\Settings\Admin; -use OCA\Settings\Admin\Server; +use OCA\Settings\Settings\Admin\Server; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; use Test\TestCase; diff --git a/apps/settings/tests/Settings/Admin/SharingTest.php b/apps/settings/tests/Settings/Admin/SharingTest.php index 6bfca5bbc04..d662c1864db 100644 --- a/apps/settings/tests/Settings/Admin/SharingTest.php +++ b/apps/settings/tests/Settings/Admin/SharingTest.php @@ -28,7 +28,7 @@ namespace OCA\Settings\Tests\Settings\Admin; -use OCA\Settings\Admin\Sharing; +use OCA\Settings\Settings\Admin\Sharing; use OCP\AppFramework\Http\TemplateResponse; use OCP\Constants; use OCP\IConfig; diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php index 8018ecaba61..ed1d2f45cd7 100644 --- a/lib/private/Settings/Manager.php +++ b/lib/private/Settings/Manager.php @@ -228,51 +228,6 @@ class Manager implements IManager { } /** - * @param string $section - * @param Closure $filter - * - * @return ISection[] - */ - private function getBuiltInAdminSettings($section, Closure $filter = null): array { - $forms = []; - - if ($section === 'overview') { - /** @var ISettings $form */ - $form = $this->container->query(\OCA\Settings\Admin\Overview::class); - if ($filter === null || $filter($form)) { - $forms[$form->getPriority()] = [$form]; - } - } - if ($section === 'server') { - /** @var ISettings $form */ - $form = $this->container->query(\OCA\Settings\Admin\Server::class); - if ($filter === null || $filter($form)) { - $forms[$form->getPriority()] = [$form]; - } - $form = $this->container->query(\OCA\Settings\Admin\Mail::class); - if ($filter === null || $filter($form)) { - $forms[$form->getPriority()] = [$form]; - } - } - if ($section === 'security') { - /** @var ISettings $form */ - $form = $this->container->query(\OCA\Settings\Admin\Security::class); - if ($filter === null || $filter($form)) { - $forms[$form->getPriority()] = [$form]; - } - } - if ($section === 'sharing') { - /** @var ISettings $form */ - $form = $this->container->query(\OCA\Settings\Admin\Sharing::class); - if ($filter === null || $filter($form)) { - $forms[$form->getPriority()] = [$form]; - } - } - - return $forms; - } - - /** * @inheritdoc */ public function getAdminSettings($section, bool $subAdminOnly = false): array { @@ -280,13 +235,12 @@ class Manager implements IManager { $subAdminSettingsFilter = function(ISettings $settings) { return $settings instanceof ISubAdminSettings; }; - $settings = $this->getBuiltInAdminSettings($section, $subAdminSettingsFilter); $appSettings = $this->getSettings('admin', $section, $subAdminSettingsFilter); } else { - $settings = $this->getBuiltInAdminSettings($section); $appSettings = $this->getSettings('admin', $section); } + $settings = []; foreach ($appSettings as $setting) { if (!isset($settings[$setting->getPriority()])) { $settings[$setting->getPriority()] = []; diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php index 06eafb6528b..bce547c9a29 100644 --- a/tests/lib/Settings/ManagerTest.php +++ b/tests/lib/Settings/ManagerTest.php @@ -102,15 +102,16 @@ class ManagerTest extends TestCase { } public function testGetAdminSettings() { - $section = $this->createMock(Sharing::class); - $section->expects($this->once()) - ->method('getPriority') + $section = $this->createMock(ISettings::class); + $section->method('getPriority') ->willReturn(13); - $this->container->expects($this->once()) - ->method('query') - ->with(Sharing::class) + $section->method('getSection') + ->willReturn('sharing'); + $this->container->method('query') + ->with('myAdminClass') ->willReturn($section); + $this->manager->registerSetting('admin', 'myAdminClass'); $settings = $this->manager->getAdminSettings('sharing'); $this->assertEquals([ @@ -119,12 +120,16 @@ class ManagerTest extends TestCase { } public function testGetAdminSettingsAsSubAdmin() { - $section = $this->createMock(Sharing::class); - $this->container->expects($this->once()) - ->method('query') - ->with(Sharing::class) + $section = $this->createMock(ISettings::class); + $section->method('getPriority') + ->willReturn(13); + $section->method('getSection') + ->willReturn('sharing'); + $this->container->method('query') + ->with('myAdminClass') ->willReturn($section); + $this->manager->registerSetting('admin', 'myAdminClass'); $settings = $this->manager->getAdminSettings('sharing', true); $this->assertEquals([], $settings); @@ -132,14 +137,16 @@ class ManagerTest extends TestCase { public function testGetSubAdminSettingsAsSubAdmin() { $section = $this->createMock(ISubAdminSettings::class); - $section->expects($this->once()) - ->method('getPriority') + $section->method('getPriority') ->willReturn(13); + $section->method('getSection') + ->willReturn('sharing'); $this->container->expects($this->once()) ->method('query') - ->with(Sharing::class) + ->with('mySubAdminClass') ->willReturn($section); + $this->manager->registerSetting('admin', 'mySubAdminClass'); $settings = $this->manager->getAdminSettings('sharing', true); $this->assertEquals([ |