Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement HTML description #225

Open
markuspoerschke opened this issue Mar 24, 2021 · 4 comments
Open

Implement HTML description #225

markuspoerschke opened this issue Mar 24, 2021 · 4 comments

Comments

@markuspoerschke
Copy link
Owner

See #55

@markuspoerschke markuspoerschke self-assigned this Mar 24, 2021
@markuspoerschke markuspoerschke modified the milestones: Version 2.0, Version 2.1 Mar 24, 2021
@markuspoerschke markuspoerschke removed this from the Version 2.1 milestone Apr 25, 2021
@markuspoerschke markuspoerschke added this to To do in Version 2.x via automation Apr 25, 2021
@markuspoerschke markuspoerschke removed their assignment Apr 25, 2021
@giorginogreg
Copy link
Contributor

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.

@benjivm
Copy link

benjivm commented Feb 8, 2022

Is this coming back?

@PJFonseca
Copy link

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

private ?string $description = null;

Then create the GET, SET and UNSET methods in there.

Then in the eventFactory, have something like this

if ($event->hasDescription()) {

but built more like this

if ($attachment->hasUri()) {

Again, this is a wild guess. :)

@hakla
Copy link

hakla commented Jan 28, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

5 participants