diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-05-07 10:13:06 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-05-07 10:13:06 +0200 |
commit | 163463dea5dbff43c318ee5d4545f29c12c54667 (patch) | |
tree | 59773f563a03972d99717232f6ee498406f816fb /lib/private/AppFramework | |
parent | e923d7b42f920cf80a9605a75b2414e07aec7263 (diff) | |
download | nextcloud-server-163463dea5dbff43c318ee5d4545f29c12c54667.tar.gz nextcloud-server-163463dea5dbff43c318ee5d4545f29c12c54667.zip |
Add InitialState Appframework service
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/AppFramework')
-rw-r--r-- | lib/private/AppFramework/DependencyInjection/DIContainer.php | 2 | ||||
-rw-r--r-- | lib/private/AppFramework/Services/InitialState.php | 51 |
2 files changed, 53 insertions, 0 deletions
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 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +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); + } +} |