Before Build Event
public function onBeforeBuildEventICS(array &$event, mixed $data, mixed $handler) : void
Fires before constructing an event of the ICS file.
Description
Trigger hook to allow the plugins to manipulate the event details before being included. This hook fires up to the number of appointments to export.
Here it is possible to overwrite the default information fetched for the events.
Parameters
- &$event
-
(array) An associative array containing the data of the event. Manipulating the attributes of this array will change the rules included into the ICS file.
uid
- this property specifies the persistent, globally unique identifier for the iCalendar object. This can be used, for example, to identify duplicate calendar streams that a client may have been given access to. Generate a md5 string of the order number because "UID" values MUST NOT include any data that might identify a user, host, domain, or any other private sensitive information.dtstamp
- in the case of an iCalendar object that specifies a "METHOD" property, this property specifies the date and time that the instance of the iCalendar object was created. In the case of an iCalendar object that doesn't specify a "METHOD" property, this property specifies the date and time that the information associated with the calendar component was last revised in the calendar store.dtstart
- this property specifies when the calendar component begins.dtend
- this property specifies the date and time that a calendar component ends.modified
- in case an event is modified through a client, it updates the Last-Modified property to the current time. When the calendar is going to refresh an event, in case the Last-Modified is not specified or it is lower than the current one, the changes will be discarded. For this reason, it is needed to specify our internal modified date in order to refresh any existing events with the updated details.summary
- this property defines a short summary or subject for the calendar component.description
- this property provides a more complete description of the calendar component than the one provided by the "SUMMARY" property.url
- this property may be used to convey a location where a more dynamic rendition of the calendar information can be found.location
- this property defines the intended venue for the activity defined by a calendar component.attendees
- this property defines an "Attendee" within a calendar component. This property might repeat up to the number of participants.
- $data
-
(JObject) A registry holding the details of the row fetched from the database.
It is possible to use
$data->get($key)
to access the internal properties of the record. - $handler
-
(VAPOrderExportDriverIcs) The instance used to export the records. Provides some helper methods to encode the ICS lines.
Return Value
None.
Example
The following example overwrites the location property, which is equals by default to the company name, with the real address of the booked employee.
/**
* Trigger hook to allow the plugins to manipulate the event
* details before being included.
*
* @param mixed &$event The event data.
* @param JObject $data The row fetched from the database.
* @param mixed $handler The current handler instance.
*
* @return void
*/
public function onBeforeBuildEventICS(&$event, $data, $handler)
{
$worktimeModel = JModelVAP::getInstance('worktime');
// fetch location according to the check-in date and booked service/employee
$id_location = $worktimeModel->getLocation(
$data->get('checkin_ts'),
$data->get('id_service'),
$data->get('id_employee')
);
if ($id_location)
{
$locationModel = JModelVAP::getInstance('location');
// fetch location details
$location = $locationModel->getInfo($id_location);
if ($location)
{
// overwrite location with the address of the employee
$event['location'] = $location->text;
}
}
}
Changelog
Version | Description |
---|---|
1.7.0 | The $data argument is now a registry instance. |
1.6.6 | Introduced. |