From a6cd23851792d331d12f97705f03499bd6851e6e Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 10 Feb 2021 20:00:04 +0100 Subject: [PATCH] Some psalm fixes for the DashboardController * Use the AppFramework IInitialState * Set return type Signed-off-by: Roeland Jago Douma --- .../lib/Controller/DashboardController.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/dashboard/lib/Controller/DashboardController.php b/apps/dashboard/lib/Controller/DashboardController.php index 63508f28c8..da8f095d43 100644 --- a/apps/dashboard/lib/Controller/DashboardController.php +++ b/apps/dashboard/lib/Controller/DashboardController.php @@ -36,18 +36,18 @@ use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Http\TemplateResponse; use OCP\App\IAppManager; +use OCP\AppFramework\Services\IInitialState; use OCP\Dashboard\IManager; use OCP\Dashboard\IWidget; use OCP\Dashboard\RegisterWidgetEvent; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; -use OCP\IInitialStateService; use OCP\IRequest; class DashboardController extends Controller { - /** @var IInitialStateService */ - private $inititalStateService; + /** @var IInitialState */ + private $inititalState; /** @var IEventDispatcher */ private $eventDispatcher; /** @var IAppManager */ @@ -66,7 +66,7 @@ class DashboardController extends Controller { public function __construct( string $appName, IRequest $request, - IInitialStateService $initialStateService, + IInitialState $initialState, IEventDispatcher $eventDispatcher, IAppManager $appManager, IManager $dashboardManager, @@ -76,7 +76,7 @@ class DashboardController extends Controller { ) { parent::__construct($appName, $request); - $this->inititalStateService = $initialStateService; + $this->inititalState = $initialState; $this->eventDispatcher = $eventDispatcher; $this->appManager = $appManager; $this->dashboardManager = $dashboardManager; @@ -119,14 +119,14 @@ class DashboardController extends Controller { $themingDefaultBackground = $this->appManager->isEnabledForUser('theming') ? $this->config->getAppValue('theming', 'backgroundMime', '') : ''; - $this->inititalStateService->provideInitialState('dashboard', 'themingDefaultBackground', $themingDefaultBackground); - $this->inititalStateService->provideInitialState('dashboard', 'panels', $widgets); - $this->inititalStateService->provideInitialState('dashboard', 'statuses', $statuses); - $this->inititalStateService->provideInitialState('dashboard', 'layout', $userLayout); - $this->inititalStateService->provideInitialState('dashboard', 'firstRun', $this->config->getUserValue($this->userId, 'dashboard', 'firstRun', '1') === '1'); - $this->inititalStateService->provideInitialState('dashboard', 'shippedBackgrounds', BackgroundService::SHIPPED_BACKGROUNDS); - $this->inititalStateService->provideInitialState('dashboard', 'background', $this->config->getUserValue($this->userId, 'dashboard', 'background', 'default')); - $this->inititalStateService->provideInitialState('dashboard', 'version', $this->config->getUserValue($this->userId, 'dashboard', 'backgroundVersion', 0)); + $this->inititalState->provideInitialState('themingDefaultBackground', $themingDefaultBackground); + $this->inititalState->provideInitialState('panels', $widgets); + $this->inititalState->provideInitialState('statuses', $statuses); + $this->inititalState->provideInitialState('layout', $userLayout); + $this->inititalState->provideInitialState('firstRun', $this->config->getUserValue($this->userId, 'dashboard', 'firstRun', '1') === '1'); + $this->inititalState->provideInitialState('shippedBackgrounds', BackgroundService::SHIPPED_BACKGROUNDS); + $this->inititalState->provideInitialState('background', $this->config->getUserValue($this->userId, 'dashboard', 'background', 'default')); + $this->inititalState->provideInitialState('version', $this->config->getUserValue($this->userId, 'dashboard', 'backgroundVersion', 0)); $this->config->setUserValue($this->userId, 'dashboard', 'firstRun', '0'); $response = new TemplateResponse('dashboard', 'index'); @@ -199,7 +199,7 @@ class DashboardController extends Controller { * @NoAdminRequired * @NoCSRFRequired */ - public function getBackground() { + public function getBackground(): Http\Response { $file = $this->backgroundService->getBackground(); if ($file !== null) { $response = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $file->getMimeType()]);