backend = $backend; $this->configService = $configService; $this->calendarIntegrationEnabled = $configService->get('calendar'); } public function getAppId(): string { return 'deck'; } public function fetchAllForCalendarHome(string $principalUri): array { if (!$this->calendarIntegrationEnabled) { return []; } $configService = $this->configService; return array_map(function (Board $board) use ($principalUri) { return new Calendar($principalUri, 'board-' . $board->getId(), $board, $this->backend); }, array_filter($this->backend->getBoards(), function ($board) use ($configService) { return $configService->isCalendarEnabled($board->getId()); })); } public function hasCalendarInCalendarHome(string $principalUri, string $calendarUri): bool { if (!$this->calendarIntegrationEnabled) { return false; } $boards = array_map(static function (Board $board) { return 'board-' . $board->getId(); }, $this->backend->getBoards()); return in_array($calendarUri, $boards, true); } public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar { if (!$this->calendarIntegrationEnabled) { return null; } if ($this->hasCalendarInCalendarHome($principalUri, $calendarUri)) { try { $board = $this->backend->getBoard((int)str_replace('board-', '', $calendarUri)); return new Calendar($principalUri, $calendarUri, $board, $this->backend); } catch (NotFound $e) { // We can just return null if we have no matching board } } return null; } }