mirror of
https://github.com/werkraum-media/events.git
synced 2024-12-23 02:06:10 +01:00
[FIX] Fix crazy die error
This commit is contained in:
parent
2f136680d0
commit
bc5801452b
3 changed files with 24 additions and 25 deletions
|
@ -23,29 +23,29 @@ class DestinationDataImportCommand extends Command {
|
|||
'storage-pid',
|
||||
InputArgument::OPTIONAL,
|
||||
'What is the storage pid?',
|
||||
'281'
|
||||
'6'
|
||||
);
|
||||
$this->addArgument(
|
||||
'region-uid',
|
||||
InputArgument::OPTIONAL,
|
||||
'What is the region uid?',
|
||||
'3'
|
||||
'1'
|
||||
);
|
||||
$this->addArgument(
|
||||
'category-parent-uid',
|
||||
InputArgument::OPTIONAL,
|
||||
'What is the default category parent uid?',
|
||||
'6'
|
||||
'52'
|
||||
);
|
||||
$this->addArgument('rest-experience',
|
||||
InputArgument::OPTIONAL,
|
||||
'What is the rest experience?',
|
||||
'arnstadt'
|
||||
'stadtmarketing-erfurt'
|
||||
);
|
||||
$this->addArgument('files-folder',
|
||||
InputArgument::OPTIONAL,
|
||||
'Where to save the image files?',
|
||||
'redaktion/arnstadt/events/'
|
||||
'staedte/erfurt/events/'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,6 +85,8 @@ class DateRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
|
|||
$query->lessThanOrEqual('start', $demand->getEnd())
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$constraints['untilnow'] = $query->greaterThanOrEqual('start', date("Y-m-d H:i:s"));
|
||||
}
|
||||
|
||||
if ($demand->getLimit() !== '') {
|
||||
|
|
|
@ -222,16 +222,14 @@ class DestinationDataImportService {
|
|||
|
||||
// Set Configuration
|
||||
$this->configurationManager->setConfiguration(array_merge($frameworkConfiguration, $persistenceConfiguration));
|
||||
|
||||
$this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
|
||||
|
||||
$this->logger->info('Starting Destination Data Import Service');
|
||||
|
||||
$restUrl = $this->restUrl . '?experience=' . $this->restExperience . '&licensekey=' . $this->restLicenseKey . '&type=' . $this->restType . '&limit=' . $this->restLimit . '&template=' . $this->restTemplate;
|
||||
|
||||
$this->logger->info('Try to get data from ' . $restUrl);
|
||||
|
||||
if ($jsonResponse = json_decode(file_get_contents($restUrl),true)) {
|
||||
$this->logger->info('Received data with ' . count($jsonResponse) . 'items');
|
||||
$this->logger->info('Received data with ' . count($jsonResponse['items']) . ' items');
|
||||
return $this->processData($jsonResponse);
|
||||
} else {
|
||||
$this->logger->error('Could not receive data.');
|
||||
|
@ -246,7 +244,9 @@ class DestinationDataImportService {
|
|||
*/
|
||||
public function processData($data) {
|
||||
|
||||
// Get seleceted region
|
||||
$this->logger->info('Processing json ' . count($data['items']));
|
||||
|
||||
// Get selected region
|
||||
$selectedRegion = $this->regionRepository->findByUid($this->regionUid);
|
||||
|
||||
foreach ($data['items'] as $event) {
|
||||
|
@ -301,10 +301,12 @@ class DestinationDataImportService {
|
|||
|
||||
}
|
||||
$this->doSlugUpdate();
|
||||
$this->logger->info('Finished import');
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $categories
|
||||
*/
|
||||
protected function setCategories(Array $categories) {
|
||||
|
@ -331,7 +333,7 @@ class DestinationDataImportService {
|
|||
*/
|
||||
protected function setDates(Array $timeIntervals) {
|
||||
|
||||
// TODO: does not seem to work -->
|
||||
// @TODO: does not seem to work -->
|
||||
//$currentEventDates = $this->tmpCurrentEvent->getDates();
|
||||
//$this->tmpCurrentEvent->removeAllDates($currentEventDates);
|
||||
// <--
|
||||
|
@ -341,7 +343,6 @@ class DestinationDataImportService {
|
|||
$this->logger->info('Found ' . count($currentEventDates) . ' to delete');
|
||||
|
||||
foreach ($currentEventDates as $currentDate) {
|
||||
//$this->logger->info('Delete ' . $currentDate->getStart()->format('Y-m-d'));
|
||||
$this->dateRepository->remove($currentDate);
|
||||
}
|
||||
|
||||
|
@ -367,9 +368,7 @@ class DestinationDataImportService {
|
|||
|
||||
} else {
|
||||
|
||||
|
||||
if ($date['freq'] == 'Daily' && empty($date['weekdays'])) {
|
||||
|
||||
$this->logger->info('Setup daily interval dates');
|
||||
$this->logger->info('Start ' . $date['start']);
|
||||
$this->logger->info('End ' . $date['repeatUntil']);
|
||||
|
@ -389,11 +388,9 @@ class DestinationDataImportService {
|
|||
$this->tmpCurrentEvent->addDate($dateObj);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if ($date['freq'] == 'Weekly' && !empty($date['weekdays'])) {
|
||||
|
||||
foreach ($date['weekdays'] as $day) {
|
||||
$this->logger->info('Setup weekly interval dates for ' . $day);
|
||||
$this->logger->info('Start ' . $date['start']);
|
||||
|
@ -416,11 +413,9 @@ class DestinationDataImportService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->logger->info('Finished setup dates');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -436,9 +431,7 @@ class DestinationDataImportService {
|
|||
$this->tmpCurrentEvent->setOrganizer($tmpOrganizer);
|
||||
continue;
|
||||
}
|
||||
|
||||
$tmpOrganizer = $this->objectManager->get(\Wrm\Events\Domain\Model\Organizer::class);
|
||||
|
||||
$tmpOrganizer->setName($address['name']);
|
||||
$tmpOrganizer->setCity($address['city']);
|
||||
$tmpOrganizer->setZip($address['zip']);
|
||||
|
@ -447,10 +440,8 @@ class DestinationDataImportService {
|
|||
$tmpOrganizer->setWeb($address['web']);
|
||||
$tmpOrganizer->setEmail($address['email']);
|
||||
$tmpOrganizer->setDistrict($address['district']);
|
||||
|
||||
$this->organizerRepository->add($tmpOrganizer);
|
||||
$this->tmpCurrentEvent->setOrganizer($tmpOrganizer);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -526,6 +517,8 @@ class DestinationDataImportService {
|
|||
*/
|
||||
protected function setAssets(Array $assets) {
|
||||
|
||||
$this->logger->info("Set assets");
|
||||
|
||||
$error = false;
|
||||
|
||||
foreach ($assets as $media_object)
|
||||
|
@ -534,6 +527,11 @@ class DestinationDataImportService {
|
|||
|
||||
$this->storage = $this->resourceFactory->getDefaultStorage();
|
||||
|
||||
if ($this->storage == null) {
|
||||
$this->logger->error('No default storage defined. Cancel import.');
|
||||
die();
|
||||
}
|
||||
|
||||
// Check if file already exists
|
||||
if (file_exists($this->environment->getPublicPath() . '/fileadmin/' . $this->filesFolder . strtolower(basename($media_object['url'])))) {
|
||||
$this->logger->info('File already exists');
|
||||
|
@ -632,7 +630,6 @@ class DestinationDataImportService {
|
|||
*/
|
||||
protected function doSlugUpdate()
|
||||
{
|
||||
|
||||
$this->logger->info('Update slugs');
|
||||
|
||||
$slugHelper = GeneralUtility::makeInstance(
|
||||
|
@ -672,4 +669,4 @@ class DestinationDataImportService {
|
|||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue