From 5e272178a5fc43aa194456b1f16c8ac443f4dd49 Mon Sep 17 00:00:00 2001 From: Dirk Koritnik Date: Thu, 1 Oct 2020 09:45:32 +0200 Subject: [PATCH] Modify ticket link import --- .../Service/DestinationDataImportService.php | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/Classes/Service/DestinationDataImportService.php b/Classes/Service/DestinationDataImportService.php index 87c1155..f41a6a7 100644 --- a/Classes/Service/DestinationDataImportService.php +++ b/Classes/Service/DestinationDataImportService.php @@ -293,10 +293,14 @@ class DestinationDataImportService { if($event['addresses']) $this->setOrganizer($event['addresses']); - // Set Social and Tickets + // Set Social if($event['media_objects']) $this->setSocial($event['media_objects']); + // Set Tickets + if($event['media_objects']) + $this->setTickets($event['media_objects']); + // Set Dates if($event['timeIntervals']) $this->setDates($event['timeIntervals']); @@ -497,11 +501,46 @@ class DestinationDataImportService { $this->tmpCurrentEvent->setYouTube($link['url']); if ($link['rel'] == "socialmedia" && $link['value'] == "Instagram") $this->tmpCurrentEvent->setInstagram($link['url']); - if ($link['rel'] == "booking") - $this->tmpCurrentEvent->setTicket($link['url']); } } + /** + * @param array $media + */ + protected function seTickets(Array $media) { + foreach ($media as $link) + { + if ($link['rel'] == "ticket") { + $this->tmpCurrentEvent->setTicket($link['url']); + break; + } elseif ($link['rel'] == "booking" && !$this->multi_array_key_exists('ticket', $media)) { + $this->tmpCurrentEvent->setTicket($link['url']); + break; + } elseif ($link['rel'] == "PRICE_KARTENLINK" && !$this->multi_array_key_exists('ticket', $media) && !$this->multi_array_key_exists('booking', $media)) { + $this->tmpCurrentEvent->setTicket($link['url']); + } + } + } + + /** + * @param string $needle + * @param array $haystack + */ + protected function multi_array_key_exists( $needle, $haystack ) { + + foreach ( $haystack as $key => $value ) { + if ( $needle == $key ) { + return true; + } + if ( is_array( $value ) ) { + if ( $this->multi_array_key_exists( $needle, $value ) == true ) { + return true; + } + } + } + return false; + } + /** * @param string $lat * @param string $lng