iCal
iCal copied to clipboard
Implement HTML description
See #55
Hi Markus, can you please merge / restore this feature? Thank you so much!
If needed, I can help you with some other things like documentation, test etc.
Is this coming back?
I looked into the code, and happily do a PR, but can't get my head around it.
I'm assuming I would need to have the attribute $descriptionHTML below this line https://github.com/markuspoerschke/iCal/blob/30f7277757024debcb839ad033ca73a0b6e3d30e/src/Domain/Entity/Event.php#L30
Then create the GET, SET and UNSET methods in there.
Then in the eventFactory, have something like this https://github.com/markuspoerschke/iCal/blob/30f7277757024debcb839ad033ca73a0b6e3d30e/src/Presentation/Factory/EventFactory.php#L93
but built more like this
https://github.com/markuspoerschke/iCal/blob/30f7277757024debcb839ad033ca73a0b6e3d30e/src/Presentation/Factory/EventFactory.php#L196
Again, this is a wild guess. :)
Hey guys, I don't have time to create a pull request for this right now. But here is a little workaround that will rewrite the description as an HTML description.
use Eluceo\iCal\Domain\Entity\Event;
use Eluceo\iCal\Presentation\Component;
use Eluceo\iCal\Presentation\Factory\EventFactory;
// Create a custom event factory that can be passed to the CalendarFactory
class CustomEventFactory extends EventFactory
{
public function createComponent(Event $event): Component
{
$description = $event->getDescription();
$event->unsetDescription();
$component = parent::createComponent($event);
return $component->withProperty(
new Component\Property(
'X-ALT-DESC',
new Component\Property\Value\TextValue($description),
[new Component\Property\Parameter('FMTTYPE', new Component\Property\Value\TextValue('text/html'))]
)
);
}
}
Now you can create a CalendarFactory
and pass it an instance of the CustomEventFactory
:
// Pass a new instance of the CustomEventFactory to the CalendarFactory
$componentFactory = new CalendarFactory(new CustomEventFactory());
The CustomEventFactory
will unset the description and add the HTML description instead. So using this workaround you cannot set both the description and the HTML description.