Files
deck/lib/Middleware/DefaultBoardMiddleware.php
Ferdinand Thiessen beb563e74e refactor: Migrate away from deprecated ILogger interface to PSR-3
Mostly replace `ILogger` with `LoggerInterface` and some minor cleanup (constructor property promotion).
Some places used the deprecated `logException` this is easy to migrate by simply use the appropriate loglevel on the logger
and place the exception under the `exception` key in the context.
Also the manual checking of the configured log level is not needed, as this is already done by the logger.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2024-08-19 14:09:13 +02:00

36 lines
1.0 KiB
PHP

<?php
/**
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Deck\Middleware;
use OCA\Deck\Service\DefaultBoardService;
use OCA\Deck\Service\PermissionService;
use OCP\AppFramework\Middleware;
use OCP\IL10N;
use Psr\Log\LoggerInterface;
class DefaultBoardMiddleware extends Middleware {
public function __construct(
private LoggerInterface $logger,
private IL10N $l10n,
private DefaultBoardService $defaultBoardService,
private PermissionService $permissionService,
private ?string $userId,
) {
}
public function beforeController($controller, $methodName) {
try {
if ($this->userId !== null && $this->defaultBoardService->checkFirstRun($this->userId) && $this->permissionService->canCreate()) {
$this->defaultBoardService->createDefaultBoard($this->l10n->t('Personal'), $this->userId, '0087C5');
}
} catch (\Throwable $e) {
$this->logger->error('Could not create default board', ['exception' => $e]);
}
}
}