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

Add documentation for ALARM component #186

Open
markuspoerschke opened this issue Oct 1, 2020 · 3 comments
Open

Add documentation for ALARM component #186

markuspoerschke opened this issue Oct 1, 2020 · 3 comments
Assignees

Comments

@markuspoerschke
Copy link
Owner

No description provided.

@markuspoerschke markuspoerschke added this to the Version 2.0 milestone Oct 1, 2020
@markuspoerschke markuspoerschke self-assigned this Oct 1, 2020
@JorisDebonnet
Copy link

Any hint you can give already? When I try:

$event->addAlarm(
	new Alarm(
		new Alarm\DisplayAction('Reminder: this task is scheduled now.'),
		new Alarm\RelativeTrigger(new \DateInterval('PT1M'))
	)
);

Then the output is:

BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:Reminder: this task is scheduled now.
TRIGGER:PT1M
END:VALARM

But that doesn't do anything in any of the calendar apps I have tested. Also, I notice in online examples that the trigger usually starts with a - sign (to indicate "before" rather than "after" the DTSTART, I assume), but I cannot create a negative DateInterval, so not sure how to implement that here.

@markuspoerschke markuspoerschke modified the milestones: Version 2.0, Version 2.1 Mar 29, 2021
@markuspoerschke markuspoerschke removed this from the Version 2.1 milestone Apr 25, 2021
@markuspoerschke
Copy link
Owner Author

@JorisDebonnet Here you can find a working example

<?php

use Eluceo\iCal\Domain\Entity\Calendar;

require_once __DIR__ . '/../vendor/autoload.php';

$event = new \Eluceo\iCal\Domain\Entity\Event();
$event->setSummary('Alarm Test');
$event->setOccurrence(
    new \Eluceo\iCal\Domain\ValueObject\TimeSpan(
        new \Eluceo\iCal\Domain\ValueObject\DateTime(new DateTimeImmutable('2021-04-25 17:30:00'), true),
        new \Eluceo\iCal\Domain\ValueObject\DateTime(new DateTimeImmutable('2021-04-25 17:45:00'), true),
    )
);

$alarmInterval = new DateInterval('PT1M');
$alarmInterval->invert = 1;
$event->addAlarm(
    new \Eluceo\iCal\Domain\ValueObject\Alarm(new \Eluceo\iCal\Domain\ValueObject\Alarm\AudioAction(),
        new \Eluceo\iCal\Domain\ValueObject\Alarm\RelativeTrigger($alarmInterval)
    )
);

// 2. Create Calendar domain entity.
$calendar = new Calendar([$event]);

echo (new \Eluceo\iCal\Presentation\Factory\CalendarFactory())->createCalendar($calendar);

The clue is indeed to make the date interval negative.

There are the following ways in PHP to make DateTimeInterval negative:

$alarmInterval = new DateInterval('PT1M');
$alarmInterval->invert = 1;

or

$alarmInterval = DateInterval::createFromDateString('1 minute ago');

@u01jmg3
Copy link

u01jmg3 commented Aug 12, 2024

Hello. I landed on this issue after looking for upgrade documentation on setting up an alarm and this was super helpful. Is this something that could go into the main website docs as it seems to be missing? Happy to start an initial PR on configuring an alarm and its display action.

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

No branches or pull requests

3 participants