-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathCalendar.php
More file actions
50 lines (39 loc) · 1.17 KB
/
Copy pathCalendar.php
File metadata and controls
50 lines (39 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Welp\IcalBundle\Component;
use Jsvrcek\ICS\Model\Calendar as vCalendar;
use Jsvrcek\ICS\Utility\Formatter;
use Jsvrcek\ICS\CalendarStream;
use Jsvrcek\ICS\CalendarExport;
/**
* Calendar component
*
* @package Welp\IcalBundle\Component
* @author Titouan BENOIT <titouan@welp.today>
*/
class Calendar extends vCalendar
{
private string $filename = 'calendar.ics';
public function getContentType(): string
{
return 'text/calendar';
}
public function export(bool $doImmediateOutput = false): string
{
//setup exporter
$calendarExport = new CalendarExport(new CalendarStream, new Formatter());
$calendarExport->addCalendar($this);
//set exporter to send items directly to output instead of storing in memory
$calendarExport->getStreamObject()->setDoImmediateOutput($doImmediateOutput);
//output .ics formatted text
return $calendarExport->getStream();
}
public function setFilename(string $filename): Calendar
{
$this->filename = $filename;
return $this;
}
public function getFilename(): string
{
return $this->filename;
}
}