Nextcloud PHP API (master)

ICalendarEventBuilder

The calendar event builder can be used to conveniently build a calendar event and then serialize it to a ICS string. The ICS string can be submitted to calendar instances implementing the {@see \OCP\Calendar\ICreateFromString} interface.

Also note this class can not be injected directly with dependency injection. Instead, inject IManager and use IManager::createEventBuilder() afterwards.

All setters return self to allow chaining method calls.

Tags
since
31.0.0

Table of Contents

Methods

addAttendee()  : self
Add a new attendee to the event.
createInCalendar()  : string
Create the event in the given calendar.
setDescription()  : self
Set the event description.
setEndDate()  : self
Set the end date, time and time zone.
setLocation()  : self
Set the event location. It can either be a physical address or a URL.
setOrganizer()  : self
Set the event organizer.
setStartDate()  : self
Set the start date, time and time zone.
setStatus()  : static
Set the event status.
setSummary()  : self
Set the event summary or title.
toIcs()  : string
Serialize the built event to an ICS string if all required properties set.

Methods

addAttendee()

Add a new attendee to the event.

public addAttendee(string $email[, string|null $commonName = null ]) : self

Adding at least one attendee requires also setting the organizer!

The "mailto:" prefix is optional and will be added automatically if it is missing.

Parameters
$email : string
$commonName : string|null = null
Tags
since
31.0.0
Return values
self

createInCalendar()

Create the event in the given calendar.

public createInCalendar(ICreateFromString $calendar) : string
Parameters
$calendar : ICreateFromString
Tags
since
31.0.0
throws
InvalidArgumentException

If required properties were not set

CalendarException

If writing the event to the calendar fails

Return values
string —

The filename of the created event

setDescription()

Set the event description.

public setDescription(string $description) : self
Parameters
$description : string
Tags
since
31.0.0
Return values
self

setEndDate()

Set the end date, time and time zone.

public setEndDate(DateTimeInterface $end) : self

This property is required!

Parameters
$end : DateTimeInterface
Tags
since
31.0.0
Return values
self

setLocation()

Set the event location. It can either be a physical address or a URL.

public setLocation(string $location) : self
Parameters
$location : string
Tags
since
31.0.0
Return values
self

setOrganizer()

Set the event organizer.

public setOrganizer(string $email[, string|null $commonName = null ]) : self

This property is required if attendees are added!

The "mailto:" prefix is optional and will be added automatically if it is missing.

Parameters
$email : string
$commonName : string|null = null
Tags
since
31.0.0
Return values
self

setStartDate()

Set the start date, time and time zone.

public setStartDate(DateTimeInterface $start) : self

This property is required!

Parameters
$start : DateTimeInterface
Tags
since
31.0.0
Return values
self

setSummary()

Set the event summary or title.

public setSummary(string $summary) : self

This property is required!

Parameters
$summary : string
Tags
since
31.0.0
Return values
self

toIcs()

Serialize the built event to an ICS string if all required properties set.

public toIcs() : string
Tags
since
31.0.0
throws
InvalidArgumentException

If required properties were not set

Return values
string —

The serialized ICS string

On this page

Search results