From 163463dea5dbff43c318ee5d4545f29c12c54667 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 7 May 2020 10:13:06 +0200 Subject: Add InitialState Appframework service Signed-off-by: Roeland Jago Douma --- .../DependencyInjection/DIContainer.php | 2 + lib/private/AppFramework/Services/InitialState.php | 51 ++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 lib/private/AppFramework/Services/InitialState.php (limited to 'lib/private/AppFramework') diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index e0c6571787e..a9d06fac22c 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -53,6 +53,7 @@ use OCP\AppFramework\Http\IOutput; use OCP\AppFramework\IAppContainer; use OCP\AppFramework\QueryException; use OCP\AppFramework\Services\IAppConfig; +use OCP\AppFramework\Services\IInitialState; use OCP\AppFramework\Utility\IControllerMethodReflector; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Files\Folder; @@ -296,6 +297,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, OC\Collaboration\Resources\Manager::class); $this->registerAlias(IAppConfig::class, OC\AppFramework\Services\AppConfig::class); + $this->registerAlias(IInitialState::class, OC\AppFramework\Services\InitialState::class); } /** diff --git a/lib/private/AppFramework/Services/InitialState.php b/lib/private/AppFramework/Services/InitialState.php new file mode 100644 index 00000000000..1f9340be2f2 --- /dev/null +++ b/lib/private/AppFramework/Services/InitialState.php @@ -0,0 +1,51 @@ + + * + * @author Roeland Jago Douma + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OC\AppFramework\Services; + +use OCP\AppFramework\Services\Closure; +use OCP\AppFramework\Services\IInitialState; +use OCP\IInitialStateService; + +class InitialState implements IInitialState { + /** @var IInitialStateService */ + private $state; + + /** @var string */ + private $appName; + + public function __construct(IInitialStateService $state, string $appName) { + $this->state = $state; + $this->appName = $appName; + } + + public function provideInitialState(string $key, $data): void { + $this->state->provideInitialState($this->appName, $key, $data); + } + + public function provideLazyInitialState(string $key, \Closure $closure): void { + $this->state->provideLazyInitialState($this->appName, $key, $closure); + } +} -- cgit v1.2.3