diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-10-03 15:47:38 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-10-04 09:35:33 +0200 |
commit | f865a3a1c2405af5c649b6d78f95b93ed60ba04f (patch) | |
tree | c7194750f2c4c88be23b0cd4ec508a59d8b61d0b /lib/public | |
parent | eba83d22bbcf45caf400704b8794acce180c5ba9 (diff) | |
download | nextcloud-server-f865a3a1c2405af5c649b6d78f95b93ed60ba04f.tar.gz nextcloud-server-f865a3a1c2405af5c649b6d78f95b93ed60ba04f.zip |
Move initial state provider to boostrap
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/AppFramework/Bootstrap/IRegistrationContext.php | 13 | ||||
-rw-r--r-- | lib/public/AppFramework/Services/InitialStateProvider.php | 49 | ||||
-rw-r--r-- | lib/public/IInitialStateService.php | 4 |
3 files changed, 66 insertions, 0 deletions
diff --git a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php index 9d910d1c693..13181cbe1cb 100644 --- a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php +++ b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php @@ -155,4 +155,17 @@ interface IRegistrationContext { * @since 20.0.0 */ public function registerAlternativeLogin(string $class): void; + + /** + * Register an initialstate provider + * + * It is allowed to register more than one provider per app. + * + * @param string $class + * + * @return void + * + * @since 21.0.0 + */ + public function registerInitialStateProvider(string $class): void; } diff --git a/lib/public/AppFramework/Services/InitialStateProvider.php b/lib/public/AppFramework/Services/InitialStateProvider.php new file mode 100644 index 00000000000..53357b48825 --- /dev/null +++ b/lib/public/AppFramework/Services/InitialStateProvider.php @@ -0,0 +1,49 @@ +<?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 OCP\AppFramework\Services; + +/** + * @since 21.0.0 + */ +abstract class InitialStateProvider implements \JsonSerializable { + + /** + * @since 21.0.0 + */ + abstract public function getKey(): string; + + /** + * @since 21.0.0 + */ + abstract public function getData(); + + /** + * @since 21.0.0 + */ + final public function jsonSerialize() { + return $this->getData(); + } +} diff --git a/lib/public/IInitialStateService.php b/lib/public/IInitialStateService.php index 905cf2a9a58..7f3e495ea22 100644 --- a/lib/public/IInitialStateService.php +++ b/lib/public/IInitialStateService.php @@ -43,6 +43,8 @@ interface IInitialStateService { * @param string $appName * @param string $key * @param bool|int|float|string|array|\JsonSerializable $data + * + * @deprecated 21 Use OCP\AppFramework\Services\IInitialState or OCP\AppFramework\Services\InitialStateProvider */ public function provideInitialState(string $appName, string $key, $data): void; @@ -58,6 +60,8 @@ interface IInitialStateService { * @param string $appName * @param string $key * @param Closure $closure returns a primitive or an object that implements JsonSerializable + * + * @deprecated 21 Use OCP\AppFramework\Services\IInitialState or OCP\AppFramework\Services\InitialStateProvider */ public function provideLazyInitialState(string $appName, string $key, Closure $closure): void; } |