ConfigService cleanup

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-11-06 14:51:26 +01:00
parent b18ebe83b6
commit ba384d9b72
3 changed files with 22 additions and 5 deletions

View File

@@ -33,11 +33,14 @@ class CalendarPlugin implements ICalendarProvider {
/** @var DeckCalendarBackend */
private $backend;
/** @var ConfigService */
private $configService;
/** @var bool */
private $calendarIntegrationEnabled;
public function __construct(DeckCalendarBackend $backend, ConfigService $configService) {
$this->backend = $backend;
$this->configService = $configService;
$this->calendarIntegrationEnabled = $configService->get('calendar');
}
@@ -50,9 +53,12 @@ class CalendarPlugin implements ICalendarProvider {
return [];
}
$configService = $this->configService;
return array_map(function (Board $board) use ($principalUri) {
return new Calendar($principalUri, 'board-' . $board->getId(), $board, $this->backend);
}, $this->backend->getBoards());
}, array_filter($this->backend->getBoards(), function ($board) use ($configService) {
return $configService->isCalendarEnabled($board->getId());
}));
}
public function hasCalendarInCalendarHome(string $principalUri, string $calendarUri): bool {