diff options
author | Julius Härtl <jus@bitgrid.net> | 2021-03-09 16:28:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-09 16:28:59 +0100 |
commit | 95af966f601832172175ea0ee77c629173b3a730 (patch) | |
tree | 44e3814baddecccf602752a89e31acbeb1890628 | |
parent | bd79d7b918eb9c4c8c543176b0407dd72ec5380e (diff) | |
parent | 2e6cab4d82d9651535f1a287afb802072928b9a8 (diff) | |
download | nextcloud-server-95af966f601832172175ea0ee77c629173b3a730.tar.gz nextcloud-server-95af966f601832172175ea0ee77c629173b3a730.zip |
Merge pull request #26017 from nextcloud/enh/boostrap/initialstate
Move initialstate bootstrap to proper types classes
-rw-r--r-- | lib/private/AppFramework/Bootstrap/RegistrationContext.php | 10 | ||||
-rw-r--r-- | lib/private/InitialStateService.php | 10 |
2 files changed, 9 insertions, 11 deletions
diff --git a/lib/private/AppFramework/Bootstrap/RegistrationContext.php b/lib/private/AppFramework/Bootstrap/RegistrationContext.php index 414345c356d..4850de94ed4 100644 --- a/lib/private/AppFramework/Bootstrap/RegistrationContext.php +++ b/lib/private/AppFramework/Bootstrap/RegistrationContext.php @@ -35,6 +35,7 @@ use OC\Support\CrashReport\Registry; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\Middleware; +use OCP\AppFramework\Services\InitialStateProvider; use OCP\Authentication\IAlternativeLogin; use OCP\Capabilities\ICapability; use OCP\Dashboard\IManager; @@ -80,7 +81,7 @@ class RegistrationContext { /** @var ServiceRegistration<IAlternativeLogin>[] */ private $alternativeLogins = []; - /** @var array[] */ + /** @var ServiceRegistration<InitialStateProvider>[] */ private $initialStates = []; /** @var ServiceRegistration<IHandler>[] */ @@ -261,10 +262,7 @@ class RegistrationContext { } public function registerInitialState(string $appId, string $class): void { - $this->initialStates[] = [ - 'appId' => $appId, - 'class' => $class, - ]; + $this->initialStates[] = new ServiceRegistration($appId, $class); } public function registerWellKnown(string $appId, string $class): void { @@ -440,7 +438,7 @@ class RegistrationContext { } /** - * @return array[] + * @return ServiceRegistration<InitialStateProvider>[] */ public function getInitialStates(): array { return $this->initialStates; diff --git a/lib/private/InitialStateService.php b/lib/private/InitialStateService.php index 7f9a084ef70..bbab831b915 100644 --- a/lib/private/InitialStateService.php +++ b/lib/private/InitialStateService.php @@ -115,25 +115,25 @@ class InitialStateService implements IInitialStateService { $initialStates = $context->getInitialStates(); foreach ($initialStates as $initialState) { try { - $provider = $this->container->query($initialState['class']); + $provider = $this->container->query($initialState->getService()); } catch (QueryException $e) { // Log an continue. We can be fault tolerant here. $this->logger->logException($e, [ 'message' => 'Could not load initial state provider dynamically: ' . $e->getMessage(), 'level' => ILogger::ERROR, - 'app' => $initialState['appId'], + 'app' => $initialState->getAppId(), ]); continue; } if (!($provider instanceof InitialStateProvider)) { // Log an continue. We can be fault tolerant here. - $this->logger->error('Initial state provider is not an InitialStateProvider instance: ' . $initialState['class'], [ - 'app' => $initialState['appId'], + $this->logger->error('Initial state provider is not an InitialStateProvider instance: ' . $initialState->getService(), [ + 'app' => $initialState->getAppId(), ]); } - $this->provideInitialState($initialState['appId'], $provider->getKey(), $provider); + $this->provideInitialState($initialState->getAppId(), $provider->getKey(), $provider); } } |