diff --git a/web/modules/custom/dpl_redia_legacy/src/Controller/RssFeeds/EventsController.php b/web/modules/custom/dpl_redia_legacy/src/Controller/RssFeeds/EventsController.php index 8a0d1935d..0f2b24f13 100644 --- a/web/modules/custom/dpl_redia_legacy/src/Controller/RssFeeds/EventsController.php +++ b/web/modules/custom/dpl_redia_legacy/src/Controller/RssFeeds/EventsController.php @@ -8,6 +8,7 @@ use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\File\FileUrlGeneratorInterface; use Drupal\Core\Url; +use Drupal\dpl_event\PriceFormatter; use Drupal\dpl_redia_legacy\RediaEvent; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -24,6 +25,7 @@ class EventsController extends ControllerBase { public function __construct( protected FileUrlGeneratorInterface $fileUrlGenerator, protected DateFormatterInterface $dateFormatter, + protected PriceFormatter $priceFormatter, ) {} /** @@ -33,6 +35,7 @@ public static function create(ContainerInterface $container): static { return new static( $container->get('file_url_generator'), $container->get('date.formatter'), + $container->get('dpl_event.price_formatter'), ); } @@ -80,7 +83,7 @@ private function getItems(): array { $items = []; foreach ($events as $event) { - $items[] = new RediaEvent($event); + $items[] = new RediaEvent($event, $this->priceFormatter); } return $items; @@ -184,6 +187,11 @@ private function buildRss(array $items, Request $request): string { $xml->writeElement('content-rss:booking-url', $item->bookingUrl); } + // Events without a price element are interpreted as free. + if ($item->prices) { + $xml->writeElement('content-rss:arrangement-price', $item->prices); + } + $xml->writeElement('content-rss:promoted', $item->promoted); $xml->endElement(); } diff --git a/web/modules/custom/dpl_redia_legacy/src/RediaEvent.php b/web/modules/custom/dpl_redia_legacy/src/RediaEvent.php index aba1253ed..1d6ff2ed1 100644 --- a/web/modules/custom/dpl_redia_legacy/src/RediaEvent.php +++ b/web/modules/custom/dpl_redia_legacy/src/RediaEvent.php @@ -6,6 +6,7 @@ use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Field\FieldItemListInterface; use Drupal\dpl_event\EventWrapper; +use Drupal\dpl_event\PriceFormatter; use Drupal\node\NodeInterface; use Drupal\recurring_events\Entity\EventInstance; @@ -28,6 +29,7 @@ class RediaEvent extends ControllerBase { public ?RediaEventMedia $media; public ?RediaEventMedia $mediaThumbnail; public ?string $bookingUrl; + public ?string $prices; // phpcs:enable /** @@ -38,7 +40,7 @@ class RediaEvent extends ControllerBase { */ public string $promoted; - public function __construct(EventInstance $event_instance) { + public function __construct(EventInstance $event_instance, PriceFormatter $price_formatter) { $event_wrapper = new EventWrapper($event_instance); $branch = $event_wrapper->getBranches()[0] ?? NULL; @@ -73,6 +75,14 @@ public function __construct(EventInstance $event_instance) { $this->branch = $branch; $this->bookingUrl = $event_wrapper->getLink(); + if (!$event_wrapper->isFreeToAttend()) { + $prices = $event_wrapper->getTicketPrices(); + $this->prices = $price_formatter->formatRawPriceRange($prices); + } + else { + $this->prices = NULL; + } + // In the old system, there was a way for editors to mark content a // promoted. However, this does not exist in the new CMS, so we wil // just hardcode it.