diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2021-03-03 11:08:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-03 11:08:42 +0100 |
commit | ce430c3613575a3cae3961473eacafce6547340a (patch) | |
tree | 62fe6eb27dabaf4297ace41acaae39ad0f0e076d /apps | |
parent | 49c46493d1c4fab800bcb26e63bc979907cd20f7 (diff) | |
parent | bc961baa40ef93b53562bd6d1de74de70fba9e8d (diff) | |
download | nextcloud-server-ce430c3613575a3cae3961473eacafce6547340a.tar.gz nextcloud-server-ce430c3613575a3cae3961473eacafce6547340a.zip |
Merge pull request #25892 from nextcloud/techdept/initialstate/part1
Move some settings over to the IInitialState
Diffstat (limited to 'apps')
-rw-r--r-- | apps/accessibility/lib/Settings/Personal.php | 26 | ||||
-rw-r--r-- | apps/files_sharing/lib/Settings/Personal.php | 10 | ||||
-rw-r--r-- | apps/settings/lib/Settings/Admin/Security.php | 13 | ||||
-rw-r--r-- | apps/settings/tests/Settings/Admin/SecurityTest.php | 6 | ||||
-rw-r--r-- | apps/workflowengine/lib/Settings/ASettings.php | 17 | ||||
-rw-r--r-- | apps/workflowengine/lib/Settings/Personal.php | 2 |
6 files changed, 29 insertions, 45 deletions
diff --git a/apps/accessibility/lib/Settings/Personal.php b/apps/accessibility/lib/Settings/Personal.php index 30df78f9766..64cfe451494 100644 --- a/apps/accessibility/lib/Settings/Personal.php +++ b/apps/accessibility/lib/Settings/Personal.php @@ -27,8 +27,8 @@ namespace OCA\Accessibility\Settings; use OCA\Accessibility\AccessibilityProvider; use OCP\AppFramework\Http\TemplateResponse; +use OCP\AppFramework\Services\IInitialState; use OCP\IConfig; -use OCP\IInitialStateService; use OCP\IL10N; use OCP\IURLGenerator; use OCP\IUserSession; @@ -55,26 +55,16 @@ class Personal implements ISettings { /** @var AccessibilityProvider */ private $accessibilityProvider; - /** @var IInitialStateService */ + /** @var IInitialState */ private $initialStateService; - /** - * Settings constructor. - * - * @param string $appName - * @param IConfig $config - * @param IUserSession $userSession - * @param IL10N $l - * @param IURLGenerator $urlGenerator - * @param AccessibilityProvider $accessibilityProvider - */ public function __construct(string $appName, IConfig $config, IUserSession $userSession, IL10N $l, IURLGenerator $urlGenerator, AccessibilityProvider $accessibilityProvider, - IInitialStateService $initialStateService) { + IInitialState $initialStateService) { $this->appName = $appName; $this->config = $config; $this->userSession = $userSession; @@ -88,7 +78,7 @@ class Personal implements ISettings { * @return TemplateResponse returns the instance with all parameters set, ready to be rendered * @since 9.1 */ - public function getForm() { + public function getForm(): TemplateResponse { Util::addScript('accessibility', 'accessibility'); Util::addStyle('accessibility', 'style'); @@ -104,8 +94,8 @@ class Personal implements ISettings { 'font' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false) ]; - $this->initialStateService->provideInitialState($this->appName, 'available-config', $availableConfig); - $this->initialStateService->provideInitialState($this->appName, 'user-config', $userConfig); + $this->initialStateService->provideInitialState('available-config', $availableConfig); + $this->initialStateService->provideInitialState('user-config', $userConfig); return new TemplateResponse($this->appName, 'settings-personal'); } @@ -114,7 +104,7 @@ class Personal implements ISettings { * @return string the section ID, e.g. 'sharing' * @since 9.1 */ - public function getSection() { + public function getSection(): string { return $this->appName; } @@ -126,7 +116,7 @@ class Personal implements ISettings { * E.g.: 70 * @since 9.1 */ - public function getPriority() { + public function getPriority(): int { return 40; } } diff --git a/apps/files_sharing/lib/Settings/Personal.php b/apps/files_sharing/lib/Settings/Personal.php index bfca0b46e07..c265a279393 100644 --- a/apps/files_sharing/lib/Settings/Personal.php +++ b/apps/files_sharing/lib/Settings/Personal.php @@ -29,20 +29,20 @@ namespace OCA\Files_Sharing\Settings; use OCA\Files_Sharing\AppInfo\Application; use OCP\AppFramework\Http\TemplateResponse; +use OCP\AppFramework\Services\IInitialState; use OCP\IConfig; -use OCP\IInitialStateService; use OCP\Settings\ISettings; class Personal implements ISettings { /** @var IConfig */ private $config; - /** @var IInitialStateService */ + /** @var IInitialState */ private $initialState; /** @var string */ private $userId; - public function __construct(IConfig $config, IInitialStateService $initialState, string $userId) { + public function __construct(IConfig $config, IInitialState $initialState, string $userId) { $this->config = $config; $this->initialState = $initialState; $this->userId = $userId; @@ -52,8 +52,8 @@ class Personal implements ISettings { $defaultAcceptSystemConfig = $this->config->getSystemValueBool('sharing.enable_share_accept', false) ? 'no' : 'yes'; $acceptDefault = $this->config->getUserValue($this->userId, Application::APP_ID, 'default_accept', $defaultAcceptSystemConfig) === 'yes'; $enforceAccept = $this->config->getSystemValueBool('sharing.force_share_accept', false); - $this->initialState->provideInitialState(Application::APP_ID, 'accept_default', $acceptDefault); - $this->initialState->provideInitialState(Application::APP_ID, 'enforce_accept', $enforceAccept); + $this->initialState->provideInitialState('accept_default', $acceptDefault); + $this->initialState->provideInitialState('enforce_accept', $enforceAccept); return new TemplateResponse('files_sharing', 'Settings/personal'); } diff --git a/apps/settings/lib/Settings/Admin/Security.php b/apps/settings/lib/Settings/Admin/Security.php index a7ff58be68f..b7f460f1bca 100644 --- a/apps/settings/lib/Settings/Admin/Security.php +++ b/apps/settings/lib/Settings/Admin/Security.php @@ -29,8 +29,8 @@ namespace OCA\Settings\Settings\Admin; use OC\Authentication\TwoFactorAuth\MandatoryTwoFactor; use OCP\AppFramework\Http\TemplateResponse; +use OCP\AppFramework\Services\IInitialState; use OCP\Encryption\IManager; -use OCP\IInitialStateService; use OCP\IUserManager; use OCP\Settings\ISettings; @@ -45,13 +45,13 @@ class Security implements ISettings { /** @var MandatoryTwoFactor */ private $mandatoryTwoFactor; - /** @var IInitialStateService */ + /** @var IInitialState */ private $initialState; public function __construct(IManager $manager, IUserManager $userManager, MandatoryTwoFactor $mandatoryTwoFactor, - IInitialStateService $initialState) { + IInitialState $initialState) { $this->manager = $manager; $this->userManager = $userManager; $this->mandatoryTwoFactor = $mandatoryTwoFactor; @@ -61,7 +61,7 @@ class Security implements ISettings { /** * @return TemplateResponse */ - public function getForm() { + public function getForm(): TemplateResponse { $encryptionModules = $this->manager->getEncryptionModules(); $defaultEncryptionModuleId = $this->manager->getDefaultEncryptionModuleId(); $encryptionModuleList = []; @@ -74,7 +74,6 @@ class Security implements ISettings { } $this->initialState->provideInitialState( - 'settings', 'mandatory2FAState', $this->mandatoryTwoFactor->getState() ); @@ -94,7 +93,7 @@ class Security implements ISettings { /** * @return string the section ID, e.g. 'sharing' */ - public function getSection() { + public function getSection(): string { return 'security'; } @@ -105,7 +104,7 @@ class Security implements ISettings { * * E.g.: 70 */ - public function getPriority() { + public function getPriority(): int { return 10; } } diff --git a/apps/settings/tests/Settings/Admin/SecurityTest.php b/apps/settings/tests/Settings/Admin/SecurityTest.php index a8a140b2c5d..ac73fc4a318 100644 --- a/apps/settings/tests/Settings/Admin/SecurityTest.php +++ b/apps/settings/tests/Settings/Admin/SecurityTest.php @@ -32,7 +32,7 @@ use OC\Authentication\TwoFactorAuth\MandatoryTwoFactor; use OC\Encryption\Manager; use OCA\Settings\Settings\Admin\Security; use OCP\AppFramework\Http\TemplateResponse; -use OCP\IInitialStateService; +use OCP\AppFramework\Services\IInitialState; use OCP\IUserManager; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -46,7 +46,7 @@ class SecurityTest extends TestCase { private $userManager; /** @var MandatoryTwoFactor|MockObject */ private $mandatoryTwoFactor; - /** @var IInitialStateService|MockObject */ + /** @var IInitialState|MockObject */ private $initialState; protected function setUp(): void { @@ -54,7 +54,7 @@ class SecurityTest extends TestCase { $this->manager = $this->getMockBuilder(Manager::class)->disableOriginalConstructor()->getMock(); $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); $this->mandatoryTwoFactor = $this->createMock(MandatoryTwoFactor::class); - $this->initialState = $this->createMock(IInitialStateService::class); + $this->initialState = $this->createMock(IInitialState::class); $this->admin = new Security( $this->manager, diff --git a/apps/workflowengine/lib/Settings/ASettings.php b/apps/workflowengine/lib/Settings/ASettings.php index 4d0d4312f16..0bd3951c40e 100644 --- a/apps/workflowengine/lib/Settings/ASettings.php +++ b/apps/workflowengine/lib/Settings/ASettings.php @@ -28,9 +28,9 @@ namespace OCA\WorkflowEngine\Settings; use OCA\WorkflowEngine\AppInfo\Application; use OCA\WorkflowEngine\Manager; use OCP\AppFramework\Http\TemplateResponse; +use OCP\AppFramework\Services\IInitialState; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; -use OCP\IInitialStateService; use OCP\IL10N; use OCP\Settings\ISettings; use OCP\WorkflowEngine\Events\LoadSettingsScriptsEvent; @@ -54,7 +54,7 @@ abstract class ASettings implements ISettings { /** @var Manager */ protected $manager; - /** @var IInitialStateService */ + /** @var IInitialState */ private $initialStateService; /** @var IConfig */ @@ -65,7 +65,7 @@ abstract class ASettings implements ISettings { IL10N $l, IEventDispatcher $eventDispatcher, Manager $manager, - IInitialStateService $initialStateService, + IInitialState $initialStateService, IConfig $config ) { $this->appName = $appName; @@ -81,7 +81,7 @@ abstract class ASettings implements ISettings { /** * @return TemplateResponse */ - public function getForm() { + public function getForm(): TemplateResponse { // @deprecated in 20.0.0: retire this one in favor of the typed event $this->eventDispatcher->dispatch( 'OCP\WorkflowEngine::loadAdditionalSettingScripts', @@ -91,33 +91,28 @@ abstract class ASettings implements ISettings { $entities = $this->manager->getEntitiesList(); $this->initialStateService->provideInitialState( - Application::APP_ID, 'entities', $this->entitiesToArray($entities) ); $operators = $this->manager->getOperatorList(); $this->initialStateService->provideInitialState( - Application::APP_ID, 'operators', $this->operatorsToArray($operators) ); $checks = $this->manager->getCheckList(); $this->initialStateService->provideInitialState( - Application::APP_ID, 'checks', $this->checksToArray($checks) ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'scope', $this->getScope() ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'appstoreenabled', $this->config->getSystemValueBool('appstoreenabled', true) ); @@ -128,7 +123,7 @@ abstract class ASettings implements ISettings { /** * @return string the section ID, e.g. 'sharing' */ - public function getSection() { + public function getSection(): ?string { return 'workflow'; } @@ -139,7 +134,7 @@ abstract class ASettings implements ISettings { * * E.g.: 70 */ - public function getPriority() { + public function getPriority(): int { return 0; } diff --git a/apps/workflowengine/lib/Settings/Personal.php b/apps/workflowengine/lib/Settings/Personal.php index 8d95dba5de8..20eb13ae48e 100644 --- a/apps/workflowengine/lib/Settings/Personal.php +++ b/apps/workflowengine/lib/Settings/Personal.php @@ -32,7 +32,7 @@ class Personal extends ASettings { return IManager::SCOPE_USER; } - public function getSection() { + public function getSection(): ?string { return $this->manager->isUserScopeEnabled() ? 'workflow' : null; } } |