FreeBusyGenerator
in package
This class helps with generating FREEBUSY reports based on existing sets of objects.
It only looks at VEVENT and VFREEBUSY objects from the sourcedata, and generates a single VFREEBUSY object.
VFREEBUSY components are described in RFC5545, The rules for what should go in a single freebusy report is taken from RFC4791, section 7.10.
Tags
Table of Contents
- $baseObject : Document
- VCALENDAR object.
- $end : DateTimeInterface|null
- End of range.
- $objects : array<string|int, mixed>
- Input objects.
- $start : DateTimeInterface|null
- Start of range.
- $timeZone : DateTimeZone
- Reference timezone.
- $vavailability : Document
- A VAVAILABILITY document.
- __construct() : mixed
- Creates the generator.
- getResult() : Component
- Parses the input data and returns a correct VFREEBUSY object, wrapped in a VCALENDAR.
- setBaseObject() : mixed
- Sets the VCALENDAR object.
- setObjects() : mixed
- Sets the input objects.
- setTimeRange() : mixed
- Sets the time range.
- setTimeZone() : mixed
- Sets the reference timezone for floating times.
- setVAvailability() : mixed
- Sets a VAVAILABILITY document.
- calculateAvailability() : mixed
- This method takes a VAVAILABILITY component and figures out all the available times.
- calculateBusy() : mixed
- This method takes an array of iCalendar objects and applies its busy times on fbData.
- generateFreeBusyCalendar() : VCalendar
- This method takes a FreeBusyData object and generates the VCALENDAR object associated with it.
Properties
$baseObject
VCALENDAR object.
protected
Document
$baseObject
$end
End of range.
protected
DateTimeInterface|null
$end
$objects
Input objects.
protected
array<string|int, mixed>
$objects
= []
$start
Start of range.
protected
DateTimeInterface|null
$start
$timeZone
Reference timezone.
protected
DateTimeZone
$timeZone
When we are calculating busy times, and we come across so-called floating times (times without a timezone), we use the reference timezone instead.
This is also used for all-day events.
This defaults to UTC.
$vavailability
A VAVAILABILITY document.
protected
Document
$vavailability
If this is set, its information will be included when calculating freebusy time.
Methods
__construct()
Creates the generator.
public
__construct([DateTimeInterface $start = null ][, DateTimeInterface $end = null ][, mixed $objects = null ][, DateTimeZone $timeZone = null ]) : mixed
Check the setTimeRange and setObjects methods for details about the arguments.
Parameters
- $start : DateTimeInterface = null
- $end : DateTimeInterface = null
- $objects : mixed = null
- $timeZone : DateTimeZone = null
Return values
mixed —getResult()
Parses the input data and returns a correct VFREEBUSY object, wrapped in a VCALENDAR.
public
getResult() : Component
Return values
Component —setBaseObject()
Sets the VCALENDAR object.
public
setBaseObject(Document $vcalendar) : mixed
If this is set, it will not be generated for you. You are responsible for setting things like the METHOD, CALSCALE, VERSION, etc..
The VFREEBUSY object will be automatically added though.
Parameters
- $vcalendar : Document
Return values
mixed —setObjects()
Sets the input objects.
public
setObjects(mixed $objects) : mixed
You must either specify a valendar object as a string, or as the parse Component. It's also possible to specify multiple objects as an array.
Parameters
- $objects : mixed
Return values
mixed —setTimeRange()
Sets the time range.
public
setTimeRange([DateTimeInterface $start = null ][, DateTimeInterface $end = null ]) : mixed
Any freebusy object falling outside of this time range will be ignored.
Parameters
- $start : DateTimeInterface = null
- $end : DateTimeInterface = null
Return values
mixed —setTimeZone()
Sets the reference timezone for floating times.
public
setTimeZone(DateTimeZone $timeZone) : mixed
Parameters
- $timeZone : DateTimeZone
Return values
mixed —setVAvailability()
Sets a VAVAILABILITY document.
public
setVAvailability(Document $vcalendar) : mixed
Parameters
- $vcalendar : Document
Return values
mixed —calculateAvailability()
This method takes a VAVAILABILITY component and figures out all the available times.
protected
calculateAvailability(FreeBusyData $fbData, VCalendar $vavailability) : mixed
Parameters
- $fbData : FreeBusyData
- $vavailability : VCalendar
Return values
mixed —calculateBusy()
This method takes an array of iCalendar objects and applies its busy times on fbData.
protected
calculateBusy(FreeBusyData $fbData, array<string|int, VCalendar> $objects) : mixed
Parameters
- $fbData : FreeBusyData
- $objects : array<string|int, VCalendar>
Return values
mixed —generateFreeBusyCalendar()
This method takes a FreeBusyData object and generates the VCALENDAR object associated with it.
protected
generateFreeBusyCalendar(FreeBusyData $fbData) : VCalendar
Parameters
- $fbData : FreeBusyData