Files
Leantime/app/Domain/Calendar/Controllers/Ical.php
wangruiguo d647428529
Some checks failed
Security Audit / Composer Security Audit (push) Has been cancelled
Security Audit / NPM Security Audit (push) Has been cancelled
Security Audit / CodeQL Analysis (push) Has been cancelled
OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
2026-09-03 18:49:20 +08:00

44 lines
1.2 KiB
PHP

<?php
namespace Leantime\Domain\Calendar\Controllers;
use Leantime\Core\Controller\Controller;
use Leantime\Core\Controller\Frontcontroller;
use Leantime\Domain\Calendar\Services\Calendar as CalendarService;
use Symfony\Component\HttpFoundation\Response;
class Ical extends Controller
{
private CalendarService $calendarService;
/**
* Initializes dependencies.
*/
public function init(CalendarService $calendarService): void
{
$this->calendarService = $calendarService;
}
/**
* Serves the iCal feed for a given calendar hash.
*
* @param array $params Request parameters
*/
public function get(array $params): Response
{
try {
$calendar = $this->calendarService->getIcalByRequestToken(
$_GET['id'] ?? '',
$params['act'] ?? ''
);
return new Response($calendar->get(), 200, [
'Content-Type' => 'text/calendar; charset=utf-8',
'Content-Disposition' => 'attachment; filename="leantime-calendar.ics"',
]);
} catch (\Exception $e) {
return Frontcontroller::redirect(BASE_URL.'/errors/404');
}
}
}