KMP PHP API Reference

ICalendarService
in package

iCalendar Service

Generates iCalendar (.ics) files for gatherings that can be imported into various calendar applications (Google Calendar, Outlook, iOS Calendar, etc.)

Implements RFC 5545 (iCalendar) format. Supports single-event downloads and multi-event subscription feeds. VEVENT UIDs use the gathering's public_id for stable, non-sequential identifiers.

Table of Contents

Methods

generateFeed()  : string
Generate a multi-event iCalendar feed for calendar subscription.
generateICalendar()  : string
Generate iCalendar content for a gathering
getFilename()  : string
Get appropriate filename for the calendar file
buildDescription()  : string
Build event description from gathering details
escapeText()  : string
Escape text for iCalendar format
foldLine()  : string
Fold long lines according to RFC 5545
formatDateTime()  : string
Format DateTime to iCalendar format (UTC)
formatTimezoneOffset()  : string
Format timezone offset for iCalendar TZOFFSET* properties
generateVEvent()  : array<string|int, string>
Generate VEVENT lines for a single gathering.
generateVTimezone()  : array<string|int, mixed>
Generate VTIMEZONE component for a given timezone

Methods

generateFeed()

Generate a multi-event iCalendar feed for calendar subscription.

public generateFeed(iterable<string|int, Gathering$gatherings, string $calendarName[, string|null $baseUrl = null ]) : string
Parameters
$gatherings : iterable<string|int, Gathering>

Gatherings to include

$calendarName : string

Display name for the calendar feed

$baseUrl : string|null = null

Base URL for building event links

Return values
string

iCalendar formatted content with multiple VEVENTs

generateICalendar()

Generate iCalendar content for a gathering

public generateICalendar(Gathering $gathering[, string|null $baseUrl = null ]) : string
Parameters
$gathering : Gathering

The gathering to create calendar entry for

$baseUrl : string|null = null

Optional base URL for the event (for public links)

Return values
string

iCalendar formatted content

getFilename()

Get appropriate filename for the calendar file

public getFilename(Gathering $gathering) : string
Parameters
$gathering : Gathering

The gathering

Return values
string

Filename (without extension)

buildDescription()

Build event description from gathering details

protected buildDescription(Gathering $gathering[, string|null $baseUrl = null ]) : string
Parameters
$gathering : Gathering

The gathering

$baseUrl : string|null = null

Optional URL to include

Return values
string

Event description

escapeText()

Escape text for iCalendar format

protected escapeText(string $text) : string

Escapes special characters according to RFC 5545:

  • Backslash () -> \
  • Semicolon (;) -> ;
  • Comma (,) -> ,
  • Newline (\n) -> \n

Also implements line folding for lines longer than 75 octets

Parameters
$text : string

Text to escape

Return values
string

Escaped and folded text

foldLine()

Fold long lines according to RFC 5545

protected foldLine(string $text[, int $maxLength = 73 ]) : string

Lines longer than 75 octets should be split with CRLF followed by a space

Parameters
$text : string

Text to fold

$maxLength : int = 73

Maximum line length (default 73)

Return values
string

Folded text

formatDateTime()

Format DateTime to iCalendar format (UTC)

protected formatDateTime(DateTime $dateTime) : string
Parameters
$dateTime : DateTime

DateTime to format

Return values
string

Formatted datetime string (YYYYMMDDTHHMMSSZ)

formatTimezoneOffset()

Format timezone offset for iCalendar TZOFFSET* properties

protected formatTimezoneOffset(int $offsetSeconds) : string

Converts seconds offset to ±HHMM format

Parameters
$offsetSeconds : int

Offset in seconds from UTC

Return values
string

Formatted offset (e.g., '+0500', '-0600')

generateVEvent()

Generate VEVENT lines for a single gathering.

protected generateVEvent(Gathering $gathering[, string|null $baseUrl = null ]) : array<string|int, string>
Parameters
$gathering : Gathering

The gathering

$baseUrl : string|null = null

Base URL for event link

Return values
array<string|int, string>

iCalendar lines for one VEVENT

generateVTimezone()

Generate VTIMEZONE component for a given timezone

protected generateVTimezone(string $timezoneId) : array<string|int, mixed>

This creates a simplified VTIMEZONE component for iCalendar files. Modern calendar applications can usually handle TZID references without the full VTIMEZONE definition, but including it ensures maximum compatibility.

Parameters
$timezoneId : string

IANA timezone identifier (e.g., 'America/Chicago')

Return values
array<string|int, mixed>

Array of iCalendar lines for the VTIMEZONE component


        
On this page

Search results