Your cart is empty!
Build Head
public function onBuildHeadExportICS(array &$head, mixed $handler) : string
Fires while constructing the head of the ICS file.
Description
Trigger hook to allow the plugins to include custom rules within the head of the ICS file.
Here it is possible to attach new rules or to overwrite the existing ones.
It is possible to include new options by returning them or by using the helper methods provided by $handler instance.
// append through the ICS handler
$handler->addLine('X-VAP-CUSTOM', 'XYZ');
// append as return value
return "X-VAP-CUSTOM:XYZ\n";
Parameters
- &$head
-
(array) An associative array containing the default head settings.
version
- this property specifies the identifier corresponding to the highest version number or the minimum and maximum range of the iCalendar specification that is required in order to interpret the iCalendar object (2.0 by default).prodid
- this property specifies the identifier for the product that created the iCalendar object. It is suggested to change this value in case you are planning to apply some changes to the structure of the ICS file.calscale
- this property defines the calendar scale used for the calendar information specified in the iCalendar object (GREGORIAN by default).calname
- this non standard property defines the default name that will be used when creating a new subscription (the company name by default).
- $handler
-
(VAPOrderExportDriverIcs) The instance used to export the records. Provides some helper methods to encode the ICS lines.
Return Value
String. The rules to append at the end of the ICS head.
Example
/**
* Trigger hook to allow the plugins to include custom options within the
* head of the ICS file.
*
* @param array &$head The default head data.
* @param mixed $handler The current handler instance.
*
* @return string The rules to include within the head.
*/
public function onBuildHeadExportICS(&$head, $handler)
{
// include a new custom rule in the form: [PROPERTY]:[VALUE]
$handler->addLine('X-VAP-LAST-UPDATE', $handler->tsToCal('now'));
// include a new custom rule in the form: [PROPERTY];[RULE]:[VALUE]
$handler->addLine(['X-VAP-URL', 'VALUE=URI'], 'https://domain.com');
// manually include a custom rule
$rules = "X-VAP-URL-SHORT;VALUE=URI:https://dmn.com\n";
// overwrite calendar name
$head['calname'] = 'My Own Calendar';
return $rules;
}
Changelog
Version | Description |
---|---|
1.7.0 | The $head argument is now passed by reference as array to allow the manipulation of the default options. |
1.6.6 | Introduced. |
Last Update: 2021-10-08 10:22
Helpful?