Skip to content

Commit

Permalink
avoid early DI of IAppManager
Browse files Browse the repository at this point in the history
- might break install

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz committed Jun 28, 2022
1 parent 28eac9c commit 771d389
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/private/Dashboard/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
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 {
Expand All @@ -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 {
Expand All @@ -63,6 +63,9 @@ public function lazyRegisterWidget(string $widgetClass, string $appId): void {
}

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 */
Expand Down

0 comments on commit 771d389

Please sign in to comment.