|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Extension "sf_event_mgt" for TYPO3 CMS. |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please read the |
|
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace DERHANSEN\SfEventMgt\Service; |
|
13
|
|
|
|
|
14
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Event; |
|
15
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
16
|
|
|
use TYPO3\CMS\Extbase\Mvc\RequestInterface; |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
class ICalendarService |
|
19
|
|
|
{ |
|
20
|
|
|
public function __construct(protected readonly FluidRenderingService $fluidRenderingService) |
|
21
|
|
|
{ |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Initiates the ICS download for the given event |
|
26
|
|
|
*/ |
|
27
|
|
|
public function downloadiCalendarFile(RequestInterface $request, Event $event): void |
|
28
|
|
|
{ |
|
29
|
|
|
$content = $this->getICalendarContent($request, $event); |
|
30
|
|
|
header('Content-Disposition: attachment; filename="event' . $event->getUid() . '.ics"'); |
|
31
|
|
|
header('Content-Type: text/calendar'); |
|
32
|
|
|
header('Content-Length: ' . strlen($content)); |
|
33
|
|
|
header('Expires: 0'); |
|
34
|
|
|
header('Cache-Control: must-revalidate'); |
|
35
|
|
|
header('Pragma: no-cache'); |
|
36
|
|
|
echo $content; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Returns the rendered iCalendar entry for the given event |
|
41
|
|
|
* according to RFC 2445 |
|
42
|
|
|
*/ |
|
43
|
|
|
public function getiCalendarContent(RequestInterface $request, Event $event): string |
|
44
|
|
|
{ |
|
45
|
|
|
$variables = [ |
|
46
|
|
|
'event' => $event, |
|
47
|
|
|
'typo3Host' => GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'), |
|
48
|
|
|
]; |
|
49
|
|
|
|
|
50
|
|
|
$icalContent = $this->fluidRenderingService->renderTemplate( |
|
51
|
|
|
$request, |
|
52
|
|
|
'Event/ICalendar.txt', |
|
53
|
|
|
$variables, |
|
54
|
|
|
'txt' |
|
55
|
|
|
); |
|
56
|
|
|
|
|
57
|
|
|
// Remove empty lines |
|
58
|
|
|
$icalContent = preg_replace('/^\h*\v+/m', '', $icalContent); |
|
59
|
|
|
// Finally replace new lines with CRLF |
|
60
|
|
|
return str_replace(chr(10), chr(13) . chr(10), $icalContent); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths