mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-24 19:36:10 +01:00
Refactoring Import Service
This commit is contained in:
parent
f6a46012a7
commit
662b088daa
5 changed files with 74 additions and 274 deletions
|
@ -2,26 +2,17 @@
|
||||||
namespace Wrm\Events\Command;
|
namespace Wrm\Events\Command;
|
||||||
|
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Core\Core\Bootstrap;
|
use TYPO3\CMS\Core\Core\Bootstrap;
|
||||||
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||||
|
|
||||||
|
use Wrm\Events\Service\CleanupService;
|
||||||
|
|
||||||
class CleanupCommand extends Command {
|
class CleanupCommand extends Command {
|
||||||
|
|
||||||
protected $restExperience;
|
|
||||||
protected $storagePid;
|
|
||||||
protected $regionUid;
|
|
||||||
protected $categoryParentUid;
|
|
||||||
protected $filesFolder;
|
|
||||||
|
|
||||||
protected $cliOutput;
|
|
||||||
protected $cliInput;
|
|
||||||
|
|
||||||
protected $cleanupService;
|
|
||||||
|
|
||||||
public function configure()
|
public function configure()
|
||||||
{
|
{
|
||||||
$this->setDescription('Cleanup Events');
|
$this->setDescription('Cleanup Events');
|
||||||
|
@ -30,14 +21,10 @@ class CleanupCommand extends Command {
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$this->cliOutput = $output;
|
|
||||||
$this->cliInput = $input;
|
|
||||||
|
|
||||||
Bootstrap::initializeBackendAuthentication();
|
Bootstrap::initializeBackendAuthentication();
|
||||||
|
|
||||||
$this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
|
return GeneralUtility::makeInstance(ObjectManager::class)
|
||||||
$this->destinationDataImportService = $this->objectManager->get('Wrm\\Events\\Service\\CleanupService');
|
->get(CleanupService::class)
|
||||||
|
->doClean();
|
||||||
return $this->cleanupService->doClean();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,20 +8,12 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Core\Core\Bootstrap;
|
use TYPO3\CMS\Core\Core\Bootstrap;
|
||||||
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||||
|
|
||||||
|
use Wrm\Events\Service\DestinationDataImportService;
|
||||||
|
|
||||||
class DestinationDataImportCommand extends Command {
|
class DestinationDataImportCommand extends Command {
|
||||||
|
|
||||||
protected $restExperience;
|
|
||||||
protected $storagePid;
|
|
||||||
protected $regionUid;
|
|
||||||
protected $categoryParentUid;
|
|
||||||
protected $filesFolder;
|
|
||||||
|
|
||||||
protected $cliOutput;
|
|
||||||
protected $cliInput;
|
|
||||||
|
|
||||||
protected $destinationDataImportService;
|
|
||||||
|
|
||||||
public function configure()
|
public function configure()
|
||||||
{
|
{
|
||||||
$this->setDescription('Import Destination Data Events');
|
$this->setDescription('Import Destination Data Events');
|
||||||
|
@ -59,26 +51,16 @@ class DestinationDataImportCommand extends Command {
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$this->cliOutput = $output;
|
|
||||||
$this->cliInput = $input;
|
|
||||||
|
|
||||||
$this->storagePid = $input->getArgument('storage-pid');
|
|
||||||
$this->regionUid = $input->getArgument('region-uid');
|
|
||||||
$this->categoryParentUid = $input->getArgument('category-parent-uid');
|
|
||||||
$this->filesFolder = $input->getArgument('files-folder');
|
|
||||||
$this->restExperience = $input->getArgument('rest-experience');
|
|
||||||
|
|
||||||
Bootstrap::initializeBackendAuthentication();
|
Bootstrap::initializeBackendAuthentication();
|
||||||
|
|
||||||
$this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
|
return GeneralUtility::makeInstance(ObjectManager::class)
|
||||||
$this->destinationDataImportService = $this->objectManager->get('Wrm\\Events\\Service\\DestinationDataImportService');
|
->get(DestinationDataImportService::class)
|
||||||
|
->import(
|
||||||
return $this->destinationDataImportService->import(
|
$input->getArgument('rest-experience'),
|
||||||
$this->restExperience,
|
$input->getArgument('storage-pid'),
|
||||||
$this->storagePid,
|
$input->getArgument('region-uid'),
|
||||||
$this->regionUid,
|
$input->getArgument('category-parent-uid'),
|
||||||
$this->categoryParentUid,
|
$input->getArgument('files-folder')
|
||||||
$this->filesFolder
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,164 +2,23 @@
|
||||||
|
|
||||||
namespace Wrm\Events\Service;
|
namespace Wrm\Events\Service;
|
||||||
|
|
||||||
use TYPO3\CMS\Core\Resource\FileRepository;
|
|
||||||
use TYPO3\CMS\Core\Resource\Index\MetaDataRepository;
|
|
||||||
use TYPO3\CMS\Core\Resource\ResourceFactory;
|
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
use TYPO3\CMS\Core\Log\LogManager;
|
||||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
|
||||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||||
use TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository;
|
|
||||||
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
|
|
||||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||||
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
|
||||||
|
|
||||||
use Wrm\Events\Domain\Repository\DateRepository;
|
|
||||||
use Wrm\Events\Domain\Repository\EventRepository;
|
|
||||||
use Wrm\Events\Domain\Repository\OrganizerRepository;
|
|
||||||
use Wrm\Events\Domain\Repository\RegionRepository;
|
|
||||||
|
|
||||||
class CleanupService {
|
class CleanupService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var
|
* Cleanup Service constructor.
|
||||||
*/
|
|
||||||
protected $restUrl;
|
|
||||||
/**
|
|
||||||
* @var
|
|
||||||
*/
|
|
||||||
protected $restLicenseKey;
|
|
||||||
/**
|
|
||||||
* @var
|
|
||||||
*/
|
|
||||||
protected $restType;
|
|
||||||
/**
|
|
||||||
* @var
|
|
||||||
*/
|
|
||||||
protected $restLimit;
|
|
||||||
/**
|
|
||||||
* @var
|
|
||||||
*/
|
|
||||||
protected $restTemplate;
|
|
||||||
/**
|
|
||||||
* @var
|
|
||||||
*/
|
|
||||||
protected $restExperience;
|
|
||||||
/**
|
|
||||||
* @var
|
|
||||||
*/
|
|
||||||
protected $storagePid;
|
|
||||||
/**
|
|
||||||
* @var
|
|
||||||
*/
|
|
||||||
protected $regionUid;
|
|
||||||
/**
|
|
||||||
* @var
|
|
||||||
*/
|
|
||||||
protected $categoryParentUid;
|
|
||||||
/**
|
|
||||||
* @var
|
|
||||||
*/
|
|
||||||
protected $filesFolder;
|
|
||||||
/**
|
|
||||||
* @var
|
|
||||||
*/
|
|
||||||
protected $storage;
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $settings = [];
|
|
||||||
/**
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $tmpCurrentEvent = FALSE;
|
|
||||||
/**
|
|
||||||
* @var
|
|
||||||
*/
|
|
||||||
protected $logger;
|
|
||||||
/**
|
|
||||||
* @var EventRepository
|
|
||||||
*/
|
|
||||||
protected $eventRepository;
|
|
||||||
/**
|
|
||||||
* @var RegionRepository
|
|
||||||
*/
|
|
||||||
protected $regionRepository;
|
|
||||||
/**
|
|
||||||
* @var OrganizerRepository
|
|
||||||
*/
|
|
||||||
protected $organizerRepository;
|
|
||||||
/**
|
|
||||||
* @var DateRepository
|
|
||||||
*/
|
|
||||||
protected $dateRepository;
|
|
||||||
/**
|
|
||||||
* @var CategoryRepository
|
|
||||||
*/
|
|
||||||
protected $sysCategoriesRepository;
|
|
||||||
/**
|
|
||||||
* @var FileRepository
|
|
||||||
*/
|
|
||||||
protected $fileRepository;
|
|
||||||
/**
|
|
||||||
* @var MetaDataRepository
|
|
||||||
*/
|
|
||||||
protected $metaDataRepository;
|
|
||||||
/**
|
|
||||||
* @var ConfigurationManager
|
|
||||||
*/
|
|
||||||
protected $configurationManager;
|
|
||||||
/**
|
|
||||||
* @var ObjectManager
|
|
||||||
*/
|
|
||||||
protected $objectManager;
|
|
||||||
/**
|
|
||||||
* @var PersistenceManager
|
|
||||||
*/
|
|
||||||
protected $persistenceManager;
|
|
||||||
/**
|
|
||||||
* @var ResourceFactory
|
|
||||||
*/
|
|
||||||
protected $resourceFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ImportService constructor.
|
|
||||||
* @param EventRepository $eventRepository
|
|
||||||
* @param RegionRepository $regionRepository
|
|
||||||
* @param OrganizerRepository $organizerRepository
|
|
||||||
* @param DateRepository $dateRepository
|
|
||||||
* @param CategoryRepository $sysCategoriesRepository
|
|
||||||
* @param FileRepository $fileRepository
|
|
||||||
* @param MetaDataRepository $metaDataRepository
|
|
||||||
* @param ConfigurationManager $configurationManager
|
* @param ConfigurationManager $configurationManager
|
||||||
* @param PersistenceManager $persistenceManager
|
|
||||||
* @param ResourceFactory $resourceFactory
|
|
||||||
* @param ObjectManager $objectManager
|
* @param ObjectManager $objectManager
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EventRepository $eventRepository,
|
|
||||||
RegionRepository $regionRepository,
|
|
||||||
OrganizerRepository $organizerRepository,
|
|
||||||
DateRepository $dateRepository,
|
|
||||||
CategoryRepository $sysCategoriesRepository,
|
|
||||||
FileRepository $fileRepository,
|
|
||||||
MetaDataRepository $metaDataRepository,
|
|
||||||
ConfigurationManager $configurationManager,
|
ConfigurationManager $configurationManager,
|
||||||
PersistenceManager $persistenceManager,
|
|
||||||
ResourceFactory $resourceFactory,
|
|
||||||
ObjectManager $objectManager
|
ObjectManager $objectManager
|
||||||
) {
|
) {
|
||||||
$this->eventRepository = $eventRepository;
|
|
||||||
$this->regionRepository = $regionRepository;
|
|
||||||
$this->organizerRepository = $organizerRepository;
|
|
||||||
$this->dateRepository = $dateRepository;
|
|
||||||
$this->sysCategoriesRepository = $sysCategoriesRepository;
|
|
||||||
$this->fileRepository = $fileRepository;
|
|
||||||
$this->metaDataRepository = $metaDataRepository;
|
|
||||||
$this->configurationManager = $configurationManager;
|
|
||||||
$this->persistenceManager = $persistenceManager;
|
|
||||||
$this->resourceFactory = $resourceFactory;
|
|
||||||
$this->objectManager = $objectManager;
|
|
||||||
|
|
||||||
// Get Typoscript Settings
|
// Get Typoscript Settings
|
||||||
$this->settings = $this->configurationManager->getConfiguration(
|
$this->settings = $this->configurationManager->getConfiguration(
|
||||||
|
@ -168,45 +27,14 @@ class CleanupService {
|
||||||
'Pi1'
|
'Pi1'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set properties
|
|
||||||
$this->restUrl = $this->settings['destinationData']['restUrl'];
|
|
||||||
$this->restLicenseKey = $this->settings['destinationData']['license'];
|
|
||||||
$this->restType = $this->settings['destinationData']['restType'];
|
|
||||||
$this->restLimit = $this->settings['destinationData']['restLimit'];
|
|
||||||
$this->restTemplate = $this->settings['destinationData']['dataTemplate'];
|
|
||||||
|
|
||||||
// Init Logger
|
$this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
|
||||||
// Nötig, damit logger arbeitet?
|
$this->logger->info('Event Cleanup Service');
|
||||||
$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = [
|
|
||||||
\TYPO3\CMS\Core\Log\LogLevel::INFO => [
|
|
||||||
'TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter' => [
|
|
||||||
'logFile' => 'typo3temp/logs/events_cleanup'
|
|
||||||
]
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->logger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class)->getLogger(__CLASS__);
|
|
||||||
$this->logger->info('Starting Destination Data Import Service');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $restExperience
|
|
||||||
* @param $storagePid
|
|
||||||
* @param $regionUid
|
|
||||||
* @param $categoryParentUid
|
|
||||||
* @param $filesFolder
|
|
||||||
*/
|
|
||||||
public function doCleanup() {
|
public function doCleanup() {
|
||||||
|
|
||||||
|
// To be done
|
||||||
|
// Hmpf
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $data
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function processData($data) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,6 +9,7 @@ use TYPO3\CMS\Core\Resource\ResourceFactory;
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Core\DataHandling\SlugHelper;
|
use TYPO3\CMS\Core\DataHandling\SlugHelper;
|
||||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||||
|
use TYPO3\CMS\Core\Log\LogManager;
|
||||||
|
|
||||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
|
||||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||||
|
@ -22,6 +23,7 @@ use Wrm\Events\Domain\Repository\EventRepository;
|
||||||
use Wrm\Events\Domain\Repository\OrganizerRepository;
|
use Wrm\Events\Domain\Repository\OrganizerRepository;
|
||||||
use Wrm\Events\Domain\Repository\RegionRepository;
|
use Wrm\Events\Domain\Repository\RegionRepository;
|
||||||
|
|
||||||
|
|
||||||
class DestinationDataImportService {
|
class DestinationDataImportService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -221,7 +223,7 @@ class DestinationDataImportService {
|
||||||
// Set Configuration
|
// Set Configuration
|
||||||
$this->configurationManager->setConfiguration(array_merge($frameworkConfiguration, $persistenceConfiguration));
|
$this->configurationManager->setConfiguration(array_merge($frameworkConfiguration, $persistenceConfiguration));
|
||||||
|
|
||||||
$this->logger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\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;
|
||||||
|
@ -288,10 +290,9 @@ class DestinationDataImportService {
|
||||||
$sysParentCategory = $this->sysCategoriesRepository->findByUid($this->categoryParentUid);
|
$sysParentCategory = $this->sysCategoriesRepository->findByUid($this->categoryParentUid);
|
||||||
foreach ($categories as $categoryTitle) {
|
foreach ($categories as $categoryTitle) {
|
||||||
$tmpSysCategory = $this->sysCategoriesRepository->findOneByTitle($categoryTitle);
|
$tmpSysCategory = $this->sysCategoriesRepository->findOneByTitle($categoryTitle);
|
||||||
if (!$tmpSysCategory)
|
if (!$tmpSysCategory) {
|
||||||
{
|
|
||||||
$this->logger->info('Creating new category: ' . $categoryTitle);
|
$this->logger->info('Creating new category: ' . $categoryTitle);
|
||||||
$tmpSysCategory = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Model\\Category');
|
$tmpSysCategory = $this->objectManager->get(\TYPO3\CMS\Extbase\Domain\Model\Category::class);
|
||||||
$tmpSysCategory->setTitle($categoryTitle);
|
$tmpSysCategory->setTitle($categoryTitle);
|
||||||
$tmpSysCategory->setParent($sysParentCategory);
|
$tmpSysCategory->setParent($sysParentCategory);
|
||||||
$tmpSysCategory->setPid($this->sysCategoriesPid);
|
$tmpSysCategory->setPid($this->sysCategoriesPid);
|
||||||
|
@ -305,6 +306,7 @@ class DestinationDataImportService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $timeIntervals
|
* @param array $timeIntervals
|
||||||
|
* @TODO: split into functions
|
||||||
*/
|
*/
|
||||||
protected function setDates(Array $timeIntervals) {
|
protected function setDates(Array $timeIntervals) {
|
||||||
|
|
||||||
|
@ -332,7 +334,7 @@ class DestinationDataImportService {
|
||||||
|
|
||||||
if (strtotime($date['start']) > $now) {
|
if (strtotime($date['start']) > $now) {
|
||||||
$this->logger->info('Setup single date');
|
$this->logger->info('Setup single date');
|
||||||
$dateObj = $this->objectManager->get('Wrm\\Events\\Domain\\Model\\Date');
|
$dateObj = $this->objectManager->get(\Wrm\Events\Domain\Model\Date::class);
|
||||||
$start = new \DateTime($date['start'], new \DateTimeZone($date['tz']));
|
$start = new \DateTime($date['start'], new \DateTimeZone($date['tz']));
|
||||||
$end = new \DateTime($date['end'], new \DateTimeZone($date['tz']));
|
$end = new \DateTime($date['end'], new \DateTimeZone($date['tz']));
|
||||||
$this->logger->info('Start transformed ' . $start->format('Y-m-d H:i'));
|
$this->logger->info('Start transformed ' . $start->format('Y-m-d H:i'));
|
||||||
|
@ -360,7 +362,7 @@ class DestinationDataImportService {
|
||||||
$eventEnd = new \DateTime();
|
$eventEnd = new \DateTime();
|
||||||
$eventEnd->setTimestamp($i);
|
$eventEnd->setTimestamp($i);
|
||||||
$eventEnd->setTime($until->format('H'), $until->format('i'));
|
$eventEnd->setTime($until->format('H'), $until->format('i'));
|
||||||
$dateObj = $this->objectManager->get('Wrm\\Events\\Domain\\Model\\Date');
|
$dateObj = $this->objectManager->get(\Wrm\Events\Domain\Model\Date::class);
|
||||||
$dateObj->setStart($eventStart);
|
$dateObj->setStart($eventStart);
|
||||||
$dateObj->setEnd($eventEnd);
|
$dateObj->setEnd($eventEnd);
|
||||||
$this->tmpCurrentEvent->addDate($dateObj);
|
$this->tmpCurrentEvent->addDate($dateObj);
|
||||||
|
@ -372,7 +374,6 @@ class DestinationDataImportService {
|
||||||
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']);
|
||||||
$this->logger->info('End ' . $date['repeatUntil']);
|
$this->logger->info('End ' . $date['repeatUntil']);
|
||||||
|
@ -387,7 +388,7 @@ class DestinationDataImportService {
|
||||||
$eventEnd = new \DateTime();
|
$eventEnd = new \DateTime();
|
||||||
$eventEnd->setTimestamp($i);
|
$eventEnd->setTimestamp($i);
|
||||||
$eventEnd->setTime($until->format('H'), $until->format('i'));
|
$eventEnd->setTime($until->format('H'), $until->format('i'));
|
||||||
$dateObj = $this->objectManager->get('Wrm\\Events\\Domain\\Model\\Date');
|
$dateObj = $this->objectManager->get(\Wrm\Events\Domain\Model\Date::class);
|
||||||
$dateObj->setStart($eventStart);
|
$dateObj->setStart($eventStart);
|
||||||
$dateObj->setEnd($eventEnd);
|
$dateObj->setEnd($eventEnd);
|
||||||
$this->tmpCurrentEvent->addDate($dateObj);
|
$this->tmpCurrentEvent->addDate($dateObj);
|
||||||
|
@ -410,9 +411,12 @@ class DestinationDataImportService {
|
||||||
{
|
{
|
||||||
if ($address['rel'] == "organizer") {
|
if ($address['rel'] == "organizer") {
|
||||||
$tmpOrganizer = $this->organizerRepository->findOneByName($address['name']);
|
$tmpOrganizer = $this->organizerRepository->findOneByName($address['name']);
|
||||||
if (!$tmpOrganizer)
|
if ($tmpOrganizer) {
|
||||||
{
|
$this->tmpCurrentEvent->setOrganizer($tmpOrganizer);
|
||||||
$tmpOrganizer = $this->objectManager->get('Wrm\\Events\\Domain\\Model\\Organizer');
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$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']);
|
||||||
|
@ -426,9 +430,6 @@ class DestinationDataImportService {
|
||||||
$this->organizerRepository->add($tmpOrganizer);
|
$this->organizerRepository->add($tmpOrganizer);
|
||||||
$this->tmpCurrentEvent->setOrganizer($tmpOrganizer);
|
$this->tmpCurrentEvent->setOrganizer($tmpOrganizer);
|
||||||
|
|
||||||
} else {
|
|
||||||
$this->tmpCurrentEvent->setOrganizer($tmpOrganizer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -475,24 +476,22 @@ class DestinationDataImportService {
|
||||||
|
|
||||||
$event = $this->eventRepository->findOneByGlobalId($globalId);
|
$event = $this->eventRepository->findOneByGlobalId($globalId);
|
||||||
|
|
||||||
if (!$event)
|
if ($event) {
|
||||||
{
|
// Global ID is found and events gets updated
|
||||||
$this->logger->info(substr($title, 0, 20) . ' does not exist');
|
$event = $this->eventRepository->findOneByGlobalId($globalId);
|
||||||
$event = $this->objectManager->get('Wrm\\Events\\Domain\\Model\\Event');
|
$this->logger->info('Found "' . substr($title, 0, 20) . '..." with global id ' . $globalId . ' in database');
|
||||||
|
return $event;
|
||||||
|
}
|
||||||
|
|
||||||
|
// New event is created
|
||||||
|
$this->logger->info(substr($title, 0, 20) . ' does not exist');
|
||||||
|
$event = $this->objectManager->get(\Wrm\Events\Domain\Model\Event::class);
|
||||||
// Create event and persist
|
// Create event and persist
|
||||||
$event->setGlobalId($globalId);
|
$event->setGlobalId($globalId);
|
||||||
$event->setCategories(new ObjectStorage());
|
$event->setCategories(new ObjectStorage());
|
||||||
$this->eventRepository->add($event);
|
$this->eventRepository->add($event);
|
||||||
$this->persistenceManager->persistAll();
|
$this->persistenceManager->persistAll();
|
||||||
|
|
||||||
$this->logger->info('Not found "' . substr($title, 0, 20) . '..." with global id ' . $globalId . ' in database. Created new one.');
|
$this->logger->info('Not found "' . substr($title, 0, 20) . '..." with global id ' . $globalId . ' in database. Created new one.');
|
||||||
} else {
|
|
||||||
// Global ID is found and events gets updated
|
|
||||||
$event = $this->eventRepository->findOneByGlobalId($globalId);
|
|
||||||
$this->logger->info('Found "' . substr($title, 0, 20) . '..." with global id ' . $globalId . ' in database');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $event;
|
return $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,6 +499,9 @@ class DestinationDataImportService {
|
||||||
* @param array $assets
|
* @param array $assets
|
||||||
*/
|
*/
|
||||||
protected function setAssets(Array $assets) {
|
protected function setAssets(Array $assets) {
|
||||||
|
|
||||||
|
$error = false;
|
||||||
|
|
||||||
foreach ($assets as $media_object)
|
foreach ($assets as $media_object)
|
||||||
{
|
{
|
||||||
if($media_object['rel'] == "default" && $media_object['type'] == "image/jpeg") {
|
if($media_object['rel'] == "default" && $media_object['type'] == "image/jpeg") {
|
||||||
|
@ -534,19 +536,20 @@ class DestinationDataImportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$error = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load File
|
* Load File
|
||||||
* @param string $file
|
* @param string $file
|
||||||
* @return bool
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function loadFile($file) {
|
protected function loadFile($file) {
|
||||||
$directory = $this->environment->getPublicPath() . "/uploads/tx_events/";
|
$directory = $this->environment->getPublicPath() . "/uploads/tx_events/";
|
||||||
$filename = basename($file);
|
$filename = basename($file);
|
||||||
$this->logger->info('Getting file ' . $file . ' as ' . $filename);
|
$this->logger->info('Getting file ' . $file . ' as ' . $filename);
|
||||||
$asset = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($file);
|
$asset = GeneralUtility::getUrl($file);
|
||||||
if ($asset) {
|
if ($asset) {
|
||||||
file_put_contents($directory . $filename, $asset);
|
file_put_contents($directory . $filename, $asset);
|
||||||
return $filename;
|
return $filename;
|
||||||
|
@ -583,19 +586,19 @@ class DestinationDataImportService {
|
||||||
$fieldname => $newId
|
$fieldname => $newId
|
||||||
);
|
);
|
||||||
|
|
||||||
$dataHandler = $this->objectManager->get('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
|
$dataHandler = $this->objectManager->get(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
|
||||||
$dataHandler->start($data, array());
|
$dataHandler->start($data, array());
|
||||||
$dataHandler->process_datamap();
|
$dataHandler->process_datamap();
|
||||||
|
|
||||||
if (count($dataHandler->errorLog) === 0) {
|
if (count($dataHandler->errorLog) === 0) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
foreach($dataHandler->errorLog as $error) {
|
foreach($dataHandler->errorLog as $error) {
|
||||||
$this->logger->info($error);
|
$this->logger->info($error);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs slug update
|
* Performs slug update
|
||||||
|
|
|
@ -24,7 +24,7 @@ plugin.tx_events {
|
||||||
dataLimit = 200
|
dataLimit = 200
|
||||||
# cat=plugin.tx_events//a; type=string; label=Data Template
|
# cat=plugin.tx_events//a; type=string; label=Data Template
|
||||||
dataTemplate = ET2014A.json
|
dataTemplate = ET2014A.json
|
||||||
# cat.plugin.tx_events//a; type=string: Label=Category Storage
|
# cat=plugin.tx_events//a; type=string; Label=Category Storage
|
||||||
categoriesPid = 54
|
categoriesPid = 54
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue