]> source.dussan.org Git - nextcloud-server.git/commitdiff
avoid early DI of IAppManager
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Wed, 22 Jun 2022 16:19:00 +0000 (18:19 +0200)
committerVincent Petry (Rebase PR Action) <PVince81@users.noreply.github.com>
Wed, 27 Jul 2022 15:11:50 +0000 (15:11 +0000)
- might break install

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
lib/private/Dashboard/Manager.php

index 8c596f470fb378480d51b3b384f6e3d0d0b63d78..6a8348ff88f2f471f66194d6bd8fbb3bbd0d4e6a 100644 (file)
@@ -31,7 +31,8 @@ use OCP\App\IAppManager;
 use OCP\Dashboard\IManager;
 use OCP\Dashboard\IWidget;
 use OCP\ILogger;
-use OCP\IServerContainer;
+use Psr\Container\ContainerExceptionInterface;
+use Psr\Container\ContainerInterface;
 use Throwable;
 
 class Manager implements IManager {
@@ -43,11 +44,10 @@ class Manager implements IManager {
        private $widgets = [];
 
        private ContainerInterface $serverContainer;
-       private IAppManager $appManager;
+       private ?IAppManager $appManager = null;
 
-       public function __construct(ContainerInterface $serverContainer, IAppManager $appManager) {
+       public function __construct(ContainerInterface $serverContainer) {
                $this->serverContainer = $serverContainer;
-               $this->appManager = $appManager;
        }
 
        private function registerWidget(IWidget $widget): void {
@@ -63,6 +63,9 @@ class Manager implements IManager {
        }
 
        public function loadLazyPanels(): void {
+               if ($this->appManager === null) {
+                       $this->appManager = $this->serverContainer->get(IAppManager::class);
+               }
                $services = $this->lazyWidgets;
                foreach ($services as $service) {
                        /** @psalm-suppress InvalidCatch */