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