Custom Properties
The domain entities in these packages are equipped with the commonly needed properties. In some cases these properties do not fully cover every use case. In the following, a way how to add custom properties to the event entity and in result to the generated iCal file is described.
In this tutorial, we will add a custom property called X-CUSTOM
to the iCal file, which can look like this:
#
1. Create a custom event domain entityFirst we need to create a custom event entity to store the additional value.
This can be done by extending from \Eluceo\iCal\Domain\Entity\Event
.
The following example shows a class with an added property named $myCustomProperty
.
It is up to you, how to implement this class.
In this example, the property is read-only.
#
2. Create a custom event factoryThe presentation components are created by factories.
It is possible to extend these factories to add custom properties to the iCal file.
In the following example, the factory reads the value $myCustomProperty
and adds its value as property X-CUSTOM
.
#
3. Let's plug it all togetherA new custom event can now be created.
To see the new property, an instance of class CustomEventFactory
must be passed to the standard calendar factory:
After that, the iCal file can be rendered like normal.
For a full sample, please have a look at example2.php
.