Skip to content

Commit

Permalink
[TASK] Use the new convenience methods
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverklee committed Sep 13, 2024
1 parent 4bb47f0 commit e633004
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Added
- Add `Venue.fullAddress` (#3399)
- Include the webinar URL in the thank-you email (#3446)
- Include the webinar URL in the calendar invite (#3445)
- Include the webinar URL in the thank-you email (#3446, #3452)
- Include the webinar URL in the calendar invite (#3445, #3452)
- Add a field for the webinar URL to events (#3380, #3384, #3451)
- Add more venue fields: contact person, email, phone number (#3362, #3363)
- Add event formats (on-site, hybrid, online) (#3343, #3361)
Expand Down
24 changes: 9 additions & 15 deletions Classes/Service/RegistrationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use OliverKlee\Seminars\BagBuilder\RegistrationBagBuilder;
use OliverKlee\Seminars\Configuration\Traits\SharedPluginConfiguration;
use OliverKlee\Seminars\Domain\Model\Event\EventDateInterface;
use OliverKlee\Seminars\Domain\Model\Venue;
use OliverKlee\Seminars\Domain\Repository\Event\EventRepository;
use OliverKlee\Seminars\Email\EmailBuilder;
use OliverKlee\Seminars\Email\Salutation;
Expand Down Expand Up @@ -524,28 +523,23 @@ private function addCalendarAttachment(EmailBuilder $emailBuilder, int $eventUid
'DTSTART:' . $this->formatDateForCalendar($begin->getTimestamp()) . "\r\n" .
'DTEND:' . $this->formatDateForCalendar($end->getTimestamp()) . "\r\n";

$venues = $event->getVenues()->getArray();
$firstVenue = $venues[0] ?? 0;
$webinarUrl = $event->getWebinarUrl();
$shouldHaveVenueAsLocation = ($firstVenue instanceof Venue)
&& (\count($venues) === 1) && $event->isAtLeastPartiallyOnSite();
$shouldHaveWebinarUrlAsLocation = $webinarUrl !== '' && $event->isAtLeastPartiallyOnline();
if ($shouldHaveVenueAsLocation) {
if ($event->isAtLeastPartiallyOnSite() && $event->hasExactlyOneVenue()) {
$firstVenue = $event->getFirstVenue();
$normalizedVenueTitle = \str_replace(
["\r\n", "\n"],
', ',
\trim($firstVenue->getTitle() . ', ' . $firstVenue->getFullAddress())
);
$content .= 'LOCATION:' . $normalizedVenueTitle . "\r\n";
} elseif ($shouldHaveWebinarUrlAsLocation) {
$content .= 'LOCATION:' . $webinarUrl . "\r\n";
} elseif ($event->hasUsableWebinarUrl()) {
$content .= 'LOCATION:' . $event->getWebinarUrl() . "\r\n";
}
if ($webinarUrl !== '' && $event->isAtLeastPartiallyOnline()) {
$content .= 'DESCRIPTION:' . $webinarUrl . "\r\n";
if ($event->hasUsableWebinarUrl()) {
$content .= 'DESCRIPTION:' . $event->getWebinarUrl() . "\r\n";
}

$organizer = $event->getFirstOrganizer();
$content .= 'ORGANIZER;CN="' . addcslashes($organizer->getName(), '"') .
$content .= 'ORGANIZER;CN="' . \addcslashes($organizer->getName(), '"') .
'":mailto:' . $organizer->getEmailAddress() . "\r\n";
$content .= "END:VEVENT\r\nEND:VCALENDAR";

Expand Down Expand Up @@ -954,8 +948,8 @@ private function buildEmailContent(

$newEvent = $this->getEventRepository()->findByUid($eventUid);
\assert($newEvent instanceof EventDateInterface);
$webinarUrl = $newEvent->getWebinarUrl();
if ($webinarUrl !== '' && $newEvent->isAtLeastPartiallyOnline()) {
if ($newEvent->hasUsableWebinarUrl()) {
$webinarUrl = $newEvent->getWebinarUrl();
$template->unhideSubparts('webinar_url', $wrapperPrefix);
$template->setMarker('webinar_url', $webinarUrl);
} else {
Expand Down

0 comments on commit e633004

Please sign in to comment.