diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-10-03 15:47:58 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-10-04 09:35:33 +0200 |
commit | b5fd75f2be1429b5f6de8b1bc81a61d116e7f79a (patch) | |
tree | 949440063ba71a8e1244b18ac5cbd9cadb0e45fc /apps/accessibility | |
parent | f865a3a1c2405af5c649b6d78f95b93ed60ba04f (diff) | |
download | nextcloud-server-b5fd75f2be1429b5f6de8b1bc81a61d116e7f79a.tar.gz nextcloud-server-b5fd75f2be1429b5f6de8b1bc81a61d116e7f79a.zip |
Move accessibility over to the new way
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/accessibility')
-rw-r--r-- | apps/accessibility/lib/AppInfo/Application.php | 13 | ||||
-rw-r--r-- | apps/accessibility/lib/Service/JSDataService.php | 9 |
2 files changed, 8 insertions, 14 deletions
diff --git a/apps/accessibility/lib/AppInfo/Application.php b/apps/accessibility/lib/AppInfo/Application.php index cd3ef069e47..5b59a244181 100644 --- a/apps/accessibility/lib/AppInfo/Application.php +++ b/apps/accessibility/lib/AppInfo/Application.php @@ -36,9 +36,7 @@ use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; -use OCP\AppFramework\IAppContainer; use OCP\IConfig; -use OCP\IInitialStateService; use OCP\IURLGenerator; use OCP\IUserSession; use function count; @@ -55,11 +53,11 @@ class Application extends App implements IBootstrap { } public function register(IRegistrationContext $context): void { + $context->registerInitialStateProvider(JSDataService::class); } public function boot(IBootContext $context): void { $context->injectFn([$this, 'injectCss']); - $context->injectFn([$this, 'registerInitialState']); } public function injectCss(IUserSession $userSession, @@ -84,13 +82,4 @@ class Application extends App implements IBootstrap { \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'media' => '(prefers-color-scheme: dark)', 'href' => $linkToCSS]); } } - - public function registerInitialState(IInitialStateService $initialState, - IAppContainer $container) { - $initialState->provideLazyInitialState(self::APP_ID, 'data', function () use ($container) { - /** @var JSDataService $data */ - $data = $container->query(JSDataService::class); - return $data; - }); - } } diff --git a/apps/accessibility/lib/Service/JSDataService.php b/apps/accessibility/lib/Service/JSDataService.php index 5ea7048b8b4..3b23748757a 100644 --- a/apps/accessibility/lib/Service/JSDataService.php +++ b/apps/accessibility/lib/Service/JSDataService.php @@ -27,10 +27,11 @@ declare(strict_types=1); namespace OCA\Accessibility\Service; use OCA\Accessibility\AppInfo\Application; +use OCP\AppFramework\Services\InitialStateProvider; use OCP\IConfig; use OCP\IUserSession; -class JSDataService implements \JsonSerializable { +class JSDataService extends InitialStateProvider { /** @var IUserSession */ private $userSession; /** @var IConfig */ @@ -44,7 +45,11 @@ class JSDataService implements \JsonSerializable { $this->config = $config; } - public function jsonSerialize() { + public function getKey(): string { + return 'data'; + } + + public function getData() { $user = $this->userSession->getUser(); if ($user === null) { |