Added conditions in iport to prevent errors

This commit is contained in:
Dirk 2019-08-13 11:52:34 +02:00
parent e9745ebd85
commit 8821bb4639

View file

@ -252,27 +252,44 @@ class DestinationDataImportService {
foreach ($data['items'] as $event) { foreach ($data['items'] as $event) {
$this->logger->info('Processing event ' . substr($event['title'], 0, 20)); $this->logger->info('Processing event ' . substr($event['title'], 0, 20));
// Event already exists? If not create one! // Event already exists? If not create one!
$this->tmpCurrentEvent = $this->getOrCreateEvent($event['global_id'], $event['title']); $this->tmpCurrentEvent = $this->getOrCreateEvent($event['global_id'], $event['title']);
// Set selected Region // Set selected Region
$this->tmpCurrentEvent->setRegion($selectedRegion); $this->tmpCurrentEvent->setRegion($selectedRegion);
// Set Title // Set Title
$this->tmpCurrentEvent->setTitle(substr($event['title'], 0, 254)); $this->tmpCurrentEvent->setTitle(substr($event['title'], 0, 254));
// Set Highlight (Is only set in rest if true) // Set Highlight (Is only set in rest if true)
if($event['highlight']) if($event['highlight'])
$this->tmpCurrentEvent->setHighlight($event['highlight']); $this->tmpCurrentEvent->setHighlight($event['highlight']);
// Set Texts // Set Texts
if($event['texts'])
$this->setTexts($event['texts']); $this->setTexts($event['texts']);
// Set address and geo data // Set address and geo data
if($event['street'] && $event['city'] && $event['zip'] && $event['country'])
$this->setAddress($event['street'], $event['city'], $event['zip'], $event['country'], $event['geo']['main']['latitude'], $event['geo']['main']['longitude']); $this->setAddress($event['street'], $event['city'], $event['zip'], $event['country'], $event['geo']['main']['latitude'], $event['geo']['main']['longitude']);
// Set Categories // Set Categories
if($event['categories'])
$this->setCategories($event['categories']); $this->setCategories($event['categories']);
// Set Organizer // Set Organizer
if($event['addresses'])
$this->setOrganizer($event['addresses']); $this->setOrganizer($event['addresses']);
// Set Dates // Set Dates
if($event['timeIntervals'])
$this->setDates($event['timeIntervals']); $this->setDates($event['timeIntervals']);
// Set Assets // Set Assets
if($event['media_objects'])
$this->setAssets($event['media_objects']); $this->setAssets($event['media_objects']);
// Update and persist // Update and persist
$this->logger->info('Persist database'); $this->logger->info('Persist database');
$this->eventRepository->update($this->tmpCurrentEvent); $this->eventRepository->update($this->tmpCurrentEvent);