Add php code sniffer to follow PSR-12

Also apply ./vendor/bin/phpcbf to auto migrate what is possible.

Relates: #8092
This commit is contained in:
Daniel Siepmann 2021-01-07 08:50:43 +01:00
parent 9bb2b3963c
commit 59272afffd
29 changed files with 255 additions and 184 deletions

View file

@ -1,18 +1,18 @@
<?php <?php
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\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 TYPO3\CMS\Extbase\Object\ObjectManager;
use Wrm\Events\Service\DestinationDataImportService; use Wrm\Events\Service\DestinationDataImportService;
class DestinationDataImportCommand extends Command { class DestinationDataImportCommand extends Command
{
public function configure() public function configure()
{ {
@ -31,12 +31,14 @@ class DestinationDataImportCommand extends Command {
'What is the region uid?', 'What is the region uid?',
'1' '1'
); );
$this->addArgument('rest-experience', $this->addArgument(
'rest-experience',
InputArgument::OPTIONAL, InputArgument::OPTIONAL,
'What is the rest experience?', 'What is the rest experience?',
'stadtmarketing-erfurt' '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?',
'staedte/erfurt/events/' 'staedte/erfurt/events/'
@ -56,4 +58,4 @@ class DestinationDataImportCommand extends Command {
$input->getArgument('files-folder') $input->getArgument('files-folder')
); );
} }
} }

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Wrm\Events\Command; namespace Wrm\Events\Command;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Wrm\Events\Command; namespace Wrm\Events\Command;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Wrm\Events\Controller; namespace Wrm\Events\Controller;
use Wrm\Events\Domain\Model\Date; use Wrm\Events\Domain\Model\Date;

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Wrm\Events\Controller; namespace Wrm\Events\Controller;
use Wrm\Events\Domain\Model\Dto\EventDemand; use Wrm\Events\Domain\Model\Dto\EventDemand;
@ -50,7 +51,7 @@ class EventController extends ActionController
/** /**
* Action list * Action list
* *
* @return void * @return void
*/ */
public function listAction() public function listAction()
@ -59,12 +60,11 @@ class EventController extends ActionController
$demand = $this->createDemandFromSettings(); $demand = $this->createDemandFromSettings();
$events = $this->eventRepository->findByDemand($demand); $events = $this->eventRepository->findByDemand($demand);
$this->view->assign('events', $events); $this->view->assign('events', $events);
} }
/** /**
* Action show * Action show
* *
* @param Event $event * @param Event $event
* @return void * @return void
*/ */
@ -75,7 +75,7 @@ class EventController extends ActionController
/** /**
* action teaser * action teaser
* *
* @return void * @return void
*/ */
public function teaserAction() public function teaserAction()
@ -96,7 +96,6 @@ class EventController extends ActionController
$this->view->assign('search', $search); $this->view->assign('search', $search);
$this->view->assign('events', $this->eventRepository->findSearchWord($search)); $this->view->assign('events', $this->eventRepository->findSearchWord($search));
} }
/** /**

View file

@ -1,7 +1,9 @@
<?php <?php
namespace Wrm\Events\Domain\Model; namespace Wrm\Events\Domain\Model;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
/** /**
* Date * Date
*/ */
@ -83,15 +85,16 @@ class Date extends AbstractEntity
* @param int $languageUid * @param int $languageUid
* @return void * @return void
*/ */
public function setLanguageUid($languageUid) { public function setLanguageUid($languageUid)
{
$this->_languageUid = $languageUid; $this->_languageUid = $languageUid;
} }
/** /**
* @return int * @return int
*/ */
public function getLanguageUid() { public function getLanguageUid()
{
return $this->_languageUid; return $this->_languageUid;
} }
} }

View file

@ -4,7 +4,8 @@ namespace Wrm\Events\Domain\Model\Dto;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
class DateDemand { class DateDemand
{
/** /**
* @var string * @var string

View file

@ -2,7 +2,8 @@
namespace Wrm\Events\Domain\Model\Dto; namespace Wrm\Events\Domain\Model\Dto;
class EventDemand { class EventDemand
{
/** /**
* @var string * @var string
@ -171,7 +172,4 @@ class EventDemand {
{ {
$this->limit = $limit; $this->limit = $limit;
} }
}
}

View file

@ -1,14 +1,15 @@
<?php <?php
namespace Wrm\Events\Domain\Model; namespace Wrm\Events\Domain\Model;
use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\Domain\Model\Category; use TYPO3\CMS\Extbase\Domain\Model\Category;
use \Wrm\Events\Domain\Repository\DateRepository; use Wrm\Events\Domain\Repository\DateRepository;
use \TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Annotation as Extbase; use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Object\ObjectManager;
use \TYPO3\CMS\Extbase\Persistence\ObjectStorage; use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/** /**
* Event * Event
@ -18,91 +19,91 @@ class Event extends AbstractEntity
/** /**
* title * title
* *
* @var string * @var string
*/ */
protected $title = ''; protected $title = '';
/** /**
* globalId * globalId
* *
* @var string * @var string
*/ */
protected $globalId = ''; protected $globalId = '';
/** /**
* slug * slug
* *
* @var string * @var string
*/ */
protected $slug = ''; protected $slug = '';
/** /**
* highlight * highlight
* *
* @var bool * @var bool
*/ */
protected $highlight = false; protected $highlight = false;
/** /**
* teaser * teaser
* *
* @var string * @var string
*/ */
protected $teaser = ''; protected $teaser = '';
/** /**
* details * details
* *
* @var string * @var string
*/ */
protected $details = ''; protected $details = '';
/** /**
* priceInfo * priceInfo
* *
* @var string * @var string
*/ */
protected $priceInfo = ''; protected $priceInfo = '';
/** /**
* name * name
* *
* @var string * @var string
*/ */
protected $name = ''; protected $name = '';
/** /**
* street * street
* *
* @var string * @var string
*/ */
protected $street = ''; protected $street = '';
/** /**
* district * district
* *
* @var string * @var string
*/ */
protected $district = ''; protected $district = '';
/** /**
* city * city
* *
* @var string * @var string
*/ */
protected $city = ''; protected $city = '';
/** /**
* zip * zip
* *
* @var string * @var string
*/ */
protected $zip = ''; protected $zip = '';
/** /**
* country * country
* *
* @var string * @var string
*/ */
protected $country = ''; protected $country = '';
@ -116,56 +117,56 @@ class Event extends AbstractEntity
/** /**
* web * web
* *
* @var string * @var string
*/ */
protected $web = ''; protected $web = '';
/** /**
* ticket * ticket
* *
* @var string * @var string
*/ */
protected $ticket = ''; protected $ticket = '';
/** /**
* facebook * facebook
* *
* @var string * @var string
*/ */
protected $facebook = ''; protected $facebook = '';
/** /**
* youtube * youtube
* *
* @var string * @var string
*/ */
protected $youtube = ''; protected $youtube = '';
/** /**
* instagram * instagram
* *
* @var string * @var string
*/ */
protected $instagram = ''; protected $instagram = '';
/** /**
* latitude * latitude
* *
* @var string * @var string
*/ */
protected $latitude = ''; protected $latitude = '';
/** /**
* longitude * longitude
* *
* @var string * @var string
*/ */
protected $longitude = ''; protected $longitude = '';
/** /**
* images * images
* *
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
* @cascade remove * @cascade remove
*/ */
@ -173,7 +174,7 @@ class Event extends AbstractEntity
/** /**
* dates * dates
* *
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Wrm\Events\Domain\Model\Date> * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Wrm\Events\Domain\Model\Date>
* @cascade remove * @cascade remove
*/ */
@ -181,21 +182,21 @@ class Event extends AbstractEntity
/** /**
* organizer * organizer
* *
* @var \Wrm\Events\Domain\Model\Organizer * @var \Wrm\Events\Domain\Model\Organizer
*/ */
protected $organizer = null; protected $organizer = null;
/** /**
* region * region
* *
* @var \Wrm\Events\Domain\Model\Region * @var \Wrm\Events\Domain\Model\Region
*/ */
protected $region = null; protected $region = null;
/** /**
* categories * categories
* *
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category> * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category>
*/ */
protected $categories; protected $categories;
@ -225,7 +226,7 @@ class Event extends AbstractEntity
/** /**
* Returns the globalId * Returns the globalId
* *
* @return string $globalId * @return string $globalId
*/ */
public function getGlobalId() public function getGlobalId()
@ -481,7 +482,7 @@ class Event extends AbstractEntity
/** /**
* @return string $instagram * @return string $instagram
*/ */
public function getInstagram() public function getInstagram()
{ {
return $this->instagram; return $this->instagram;
@ -489,12 +490,12 @@ class Event extends AbstractEntity
/** /**
* @param string $instagram * @param string $instagram
*/ */
public function setInstagram(string $instagram) public function setInstagram(string $instagram)
{ {
$this->instagram = $instagram; $this->instagram = $instagram;
} }
/** /**
* @return string $latitude * @return string $latitude
*/ */
@ -606,7 +607,8 @@ class Event extends AbstractEntity
* @param ObjectStorage $dates * @param ObjectStorage $dates
* @return void * @return void
*/ */
public function removeAllDates(ObjectStorage $dates) { public function removeAllDates(ObjectStorage $dates)
{
$this->dates->removeAll($dates); $this->dates->removeAll($dates);
} }
@ -714,14 +716,16 @@ class Event extends AbstractEntity
* @param int $languageUid * @param int $languageUid
* @return void * @return void
*/ */
public function setLanguageUid($languageUid) { public function setLanguageUid($languageUid)
{
$this->_languageUid = $languageUid; $this->_languageUid = $languageUid;
} }
/** /**
* @return int * @return int
*/ */
public function getLanguageUid() { public function getLanguageUid()
{
return $this->_languageUid; return $this->_languageUid;
} }
} }

View file

@ -1,7 +1,9 @@
<?php <?php
namespace Wrm\Events\Domain\Model; namespace Wrm\Events\Domain\Model;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
/*** /***
* *
* This file is part of the "DD Events" Extension for TYPO3 CMS. * This file is part of the "DD Events" Extension for TYPO3 CMS.
@ -20,56 +22,56 @@ class Organizer extends AbstractEntity
/** /**
* name * name
* *
* @var string * @var string
*/ */
protected $name = ''; protected $name = '';
/** /**
* street * street
* *
* @var string * @var string
*/ */
protected $street = ''; protected $street = '';
/** /**
* district * district
* *
* @var string * @var string
*/ */
protected $district = ''; protected $district = '';
/** /**
* city * city
* *
* @var string * @var string
*/ */
protected $city = ''; protected $city = '';
/** /**
* zip * zip
* *
* @var string * @var string
*/ */
protected $zip = ''; protected $zip = '';
/** /**
* phone * phone
* *
* @var string * @var string
*/ */
protected $phone = ''; protected $phone = '';
/** /**
* web * web
* *
* @var string * @var string
*/ */
protected $web = ''; protected $web = '';
/** /**
* email * email
* *
* @var string * @var string
*/ */
protected $email = ''; protected $email = '';
@ -81,7 +83,7 @@ class Organizer extends AbstractEntity
/** /**
* Returns the name * Returns the name
* *
* @return string $name * @return string $name
*/ */
public function getName() public function getName()
@ -91,7 +93,7 @@ class Organizer extends AbstractEntity
/** /**
* Sets the name * Sets the name
* *
* @param string $name * @param string $name
* @return void * @return void
*/ */
@ -102,7 +104,7 @@ class Organizer extends AbstractEntity
/** /**
* Returns the street * Returns the street
* *
* @return string $street * @return string $street
*/ */
public function getStreet() public function getStreet()
@ -112,7 +114,7 @@ class Organizer extends AbstractEntity
/** /**
* Sets the street * Sets the street
* *
* @param string $street * @param string $street
* @return void * @return void
*/ */
@ -123,7 +125,7 @@ class Organizer extends AbstractEntity
/** /**
* Returns the district * Returns the district
* *
* @return string $district * @return string $district
*/ */
public function getDistrict() public function getDistrict()
@ -133,7 +135,7 @@ class Organizer extends AbstractEntity
/** /**
* Sets the district * Sets the district
* *
* @param string $district * @param string $district
* @return void * @return void
*/ */
@ -144,7 +146,7 @@ class Organizer extends AbstractEntity
/** /**
* Returns the city * Returns the city
* *
* @return string $city * @return string $city
*/ */
public function getCity() public function getCity()
@ -154,7 +156,7 @@ class Organizer extends AbstractEntity
/** /**
* Sets the city * Sets the city
* *
* @param string $city * @param string $city
* @return void * @return void
*/ */
@ -165,7 +167,7 @@ class Organizer extends AbstractEntity
/** /**
* Returns the zip * Returns the zip
* *
* @return string $zip * @return string $zip
*/ */
public function getZip() public function getZip()
@ -175,7 +177,7 @@ class Organizer extends AbstractEntity
/** /**
* Sets the zip * Sets the zip
* *
* @param string $zip * @param string $zip
* @return void * @return void
*/ */
@ -186,7 +188,7 @@ class Organizer extends AbstractEntity
/** /**
* Returns the phone * Returns the phone
* *
* @return string $phone * @return string $phone
*/ */
public function getPhone() public function getPhone()
@ -196,7 +198,7 @@ class Organizer extends AbstractEntity
/** /**
* Sets the phone * Sets the phone
* *
* @param string $phone * @param string $phone
* @return void * @return void
*/ */
@ -207,7 +209,7 @@ class Organizer extends AbstractEntity
/** /**
* Returns the web * Returns the web
* *
* @return string $web * @return string $web
*/ */
public function getWeb() public function getWeb()
@ -217,7 +219,7 @@ class Organizer extends AbstractEntity
/** /**
* Sets the web * Sets the web
* *
* @param string $web * @param string $web
* @return void * @return void
*/ */
@ -228,7 +230,7 @@ class Organizer extends AbstractEntity
/** /**
* Returns the email * Returns the email
* *
* @return string $email * @return string $email
*/ */
public function getEmail() public function getEmail()
@ -238,7 +240,7 @@ class Organizer extends AbstractEntity
/** /**
* Sets the email * Sets the email
* *
* @param string $email * @param string $email
* @return void * @return void
*/ */
@ -262,7 +264,7 @@ class Organizer extends AbstractEntity
* Do not modify this method! * Do not modify this method!
* It will be rewritten on each save in the extension builder * It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead * You may modify the constructor of this class instead
* *
* @return void * @return void
*/ */
protected function initStorageObjects() protected function initStorageObjects()
@ -273,14 +275,16 @@ class Organizer extends AbstractEntity
* @param int $languageUid * @param int $languageUid
* @return void * @return void
*/ */
public function setLanguageUid($languageUid) { public function setLanguageUid($languageUid)
{
$this->_languageUid = $languageUid; $this->_languageUid = $languageUid;
} }
/** /**
* @return int * @return int
*/ */
public function getLanguageUid() { public function getLanguageUid()
{
return $this->_languageUid; return $this->_languageUid;
} }
} }

View file

@ -1,7 +1,9 @@
<?php <?php
namespace Wrm\Events\Domain\Model; namespace Wrm\Events\Domain\Model;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
/*** /***
* *
* This file is part of the "DD Events" Extension for TYPO3 CMS. * This file is part of the "DD Events" Extension for TYPO3 CMS.
@ -20,11 +22,11 @@ class Region extends AbstractEntity
/** /**
* title * title
* *
* @var string * @var string
*/ */
protected $title = ''; protected $title = '';
/** /**
* @var int * @var int
*/ */
@ -32,7 +34,7 @@ class Region extends AbstractEntity
/** /**
* Returns the title * Returns the title
* *
* @return string $title * @return string $title
*/ */
public function getTitle() public function getTitle()
@ -42,7 +44,7 @@ class Region extends AbstractEntity
/** /**
* Sets the title * Sets the title
* *
* @param string $title * @param string $title
* @return void * @return void
*/ */
@ -66,7 +68,7 @@ class Region extends AbstractEntity
* Do not modify this method! * Do not modify this method!
* It will be rewritten on each save in the extension builder * It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead * You may modify the constructor of this class instead
* *
* @return void * @return void
*/ */
protected function initStorageObjects() protected function initStorageObjects()
@ -77,14 +79,16 @@ class Region extends AbstractEntity
* @param int $languageUid * @param int $languageUid
* @return void * @return void
*/ */
public function setLanguageUid($languageUid) { public function setLanguageUid($languageUid)
{
$this->_languageUid = $languageUid; $this->_languageUid = $languageUid;
} }
/** /**
* @return int * @return int
*/ */
public function getLanguageUid() { public function getLanguageUid()
{
return $this->_languageUid; return $this->_languageUid;
} }
} }

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Wrm\Events\Domain\Repository; namespace Wrm\Events\Domain\Repository;
use TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface; use TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface;
@ -67,7 +68,7 @@ class DateRepository extends Repository
$constraints['region'] = $query->equals('event.region', $demand->getRegion()); $constraints['region'] = $query->equals('event.region', $demand->getRegion());
} }
if ($demand->getHighlight() !== FALSE) { if ($demand->getHighlight() !== false) {
$constraints['highlight'] = $query->equals('event.highlight', $demand->getHighlight()); $constraints['highlight'] = $query->equals('event.highlight', $demand->getHighlight());
} }
@ -183,5 +184,4 @@ class DateRepository extends Repository
return $statement->execute()->fetchAll(); return $statement->execute()->fetchAll();
} }
} }

View file

@ -1,7 +1,9 @@
<?php <?php
namespace Wrm\Events\Domain\Repository; namespace Wrm\Events\Domain\Repository;
use TYPO3\CMS\Extbase\Persistence\Repository; use TYPO3\CMS\Extbase\Persistence\Repository;
/** /**
* This file is part of the TYPO3 CMS project. * This file is part of the TYPO3 CMS project.
* *
@ -143,5 +145,4 @@ class EventRepository extends Repository
$query->setLimit(20); $query->setLimit(20);
return $query->execute(); return $query->execute();
} }
}
}

View file

@ -1,7 +1,9 @@
<?php <?php
namespace Wrm\Events\Domain\Repository; namespace Wrm\Events\Domain\Repository;
use TYPO3\CMS\Extbase\Persistence\Repository; use TYPO3\CMS\Extbase\Persistence\Repository;
/** /**
* This file is part of the TYPO3 CMS project. * This file is part of the TYPO3 CMS project.
* *
@ -20,4 +22,4 @@ use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
class OrganizerRepository extends Repository class OrganizerRepository extends Repository
{ {
} }

View file

@ -1,7 +1,9 @@
<?php <?php
namespace Wrm\Events\Domain\Repository; namespace Wrm\Events\Domain\Repository;
use TYPO3\CMS\Extbase\Persistence\Repository; use TYPO3\CMS\Extbase\Persistence\Repository;
/** /**
* This file is part of the TYPO3 CMS project. * This file is part of the TYPO3 CMS project.
* *
@ -20,4 +22,4 @@ use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
class RegionRepository extends Repository class RegionRepository extends Repository
{ {
} }

View file

@ -15,21 +15,19 @@ 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\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\Domain\Repository\CategoryRepository;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; 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 TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use Wrm\Events\Domain\Repository\DateRepository; use Wrm\Events\Domain\Repository\DateRepository;
use Wrm\Events\Domain\Repository\EventRepository; 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 { {
/** /**
* @var * @var
@ -210,7 +208,8 @@ class DestinationDataImportService {
* @param $regionUid * @param $regionUid
* @param $filesFolder * @param $filesFolder
*/ */
public function import($restExperience, $storagePid, $regionUid, $filesFolder) { public function import($restExperience, $storagePid, $regionUid, $filesFolder)
{
$this->restExperience = $restExperience; $this->restExperience = $restExperience;
$this->storagePid = $storagePid; $this->storagePid = $storagePid;
@ -237,21 +236,21 @@ class DestinationDataImportService {
$restUrl = $this->restUrl . '?experience=' . $this->restExperience . '&licensekey=' . $this->restLicenseKey . '&type=' . $this->restType . '&mode=' . $this->restMode . '&limit=' . $this->restLimit . '&template=' . $this->restTemplate; $restUrl = $this->restUrl . '?experience=' . $this->restExperience . '&licensekey=' . $this->restLicenseKey . '&type=' . $this->restType . '&mode=' . $this->restMode . '&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']) . ' 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.');
return 1; return 1;
} }
} }
/** /**
* @param $data * @param $data
* @return int * @return int
*/ */
public function processData($data) { public function processData($data)
{
$this->logger->info('Processing json ' . count($data['items'])); $this->logger->info('Processing json ' . count($data['items']));
@ -259,7 +258,6 @@ class DestinationDataImportService {
$selectedRegion = $this->regionRepository->findByUid($this->regionUid); $selectedRegion = $this->regionRepository->findByUid($this->regionUid);
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!
@ -275,50 +273,59 @@ class DestinationDataImportService {
$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']) if ($event['texts']) {
$this->setTexts($event['texts']); $this->setTexts($event['texts']);
}
// Set address and geo data // Set address and geo data
if($event['name'] || $event['street'] || $event['city'] || $event['zip'] || $event['country'] || $event['web']) if ($event['name'] || $event['street'] || $event['city'] || $event['zip'] || $event['country'] || $event['web']) {
$this->setAddress($event); $this->setAddress($event);
}
// Set LatLng // Set LatLng
if($event['geo']['main']['latitude'] && $event['geo']['main']['longitude']) if ($event['geo']['main']['latitude'] && $event['geo']['main']['longitude']) {
$this->setLatLng($event['geo']['main']['latitude'], $event['geo']['main']['longitude']); $this->setLatLng($event['geo']['main']['latitude'], $event['geo']['main']['longitude']);
}
// Set Categories // Set Categories
if($event['categories']) if ($event['categories']) {
$this->setCategories($event['categories']); $this->setCategories($event['categories']);
}
// Set Organizer // Set Organizer
if($event['addresses']) if ($event['addresses']) {
$this->setOrganizer($event['addresses']); $this->setOrganizer($event['addresses']);
}
// Set Social // Set Social
if($event['media_objects']) if ($event['media_objects']) {
$this->setSocial($event['media_objects']); $this->setSocial($event['media_objects']);
}
// Set Tickets // Set Tickets
if($event['media_objects']) if ($event['media_objects']) {
$this->setTickets($event['media_objects']); $this->setTickets($event['media_objects']);
}
// Set Dates // Set Dates
if($event['timeIntervals']) if ($event['timeIntervals']) {
$this->setDates($event['timeIntervals']); $this->setDates($event['timeIntervals']);
}
// Set Assets // Set Assets
if($event['media_objects']) 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);
$this->persistenceManager->persistAll(); $this->persistenceManager->persistAll();
} }
$this->doSlugUpdate(); $this->doSlugUpdate();
$this->logger->info('Finished import'); $this->logger->info('Finished import');
@ -329,7 +336,8 @@ class DestinationDataImportService {
* *
* @param array $categories * @param array $categories
*/ */
protected function setCategories(Array $categories) { protected function setCategories(array $categories)
{
$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);
@ -351,7 +359,8 @@ class DestinationDataImportService {
* @param array $timeIntervals * @param array $timeIntervals
* @TODO: split into functions * @TODO: split into functions
*/ */
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();
@ -370,10 +379,8 @@ class DestinationDataImportService {
$today = $today->getTimestamp(); $today = $today->getTimestamp();
foreach ($timeIntervals as $date) { foreach ($timeIntervals as $date) {
// Check if dates are given as interval or not // Check if dates are given as interval or not
if (empty($date['interval'])) { if (empty($date['interval'])) {
if (strtotime($date['start']) > $today) { if (strtotime($date['start']) > $today) {
$this->logger->info('Setup single date'); $this->logger->info('Setup single date');
$dateObj = $this->objectManager->get(Date::class); $dateObj = $this->objectManager->get(Date::class);
@ -387,18 +394,15 @@ class DestinationDataImportService {
$dateObj->setEnd($end); $dateObj->setEnd($end);
$this->tmpCurrentEvent->addDate($dateObj); $this->tmpCurrentEvent->addDate($dateObj);
} }
} else { } else {
if ($date['freq'] == 'Daily' && empty($date['weekdays']) && !empty($date['repeatUntil'])) { if ($date['freq'] == 'Daily' && empty($date['weekdays']) && !empty($date['repeatUntil'])) {
$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']);
$start = new \DateTime($date['start'], new \DateTimeZone($date['tz'])); $start = new \DateTime($date['start'], new \DateTimeZone($date['tz']));
$until = new \DateTime($date['repeatUntil'], new \DateTimeZone($date['tz'])); $until = new \DateTime($date['repeatUntil'], new \DateTimeZone($date['tz']));
for($i = strtotime($start->format('l'), $start->getTimestamp()); $i <= $until->getTimestamp(); $i = strtotime('+1 day', $i)) { for ($i = strtotime($start->format('l'), $start->getTimestamp()); $i <= $until->getTimestamp(); $i = strtotime('+1 day', $i)) {
if ($i >= $today) { if ($i >= $today) {
$eventStart = new \DateTime(); $eventStart = new \DateTime();
$eventStart->setTimestamp($i); $eventStart->setTimestamp($i);
@ -413,10 +417,7 @@ class DestinationDataImportService {
$this->tmpCurrentEvent->addDate($dateObj); $this->tmpCurrentEvent->addDate($dateObj);
} }
} }
} elseif ($date['freq'] == 'Weekly' && !empty($date['weekdays']) && !empty($date['repeatUntil'])) {
}
else if ($date['freq'] == 'Weekly' && !empty($date['weekdays']) && !empty($date['repeatUntil'])) {
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']);
@ -424,7 +425,7 @@ class DestinationDataImportService {
$start = new \DateTime($date['start'], new \DateTimeZone($date['tz'])); $start = new \DateTime($date['start'], new \DateTimeZone($date['tz']));
$until = new \DateTime($date['repeatUntil'], new \DateTimeZone($date['tz'])); $until = new \DateTime($date['repeatUntil'], new \DateTimeZone($date['tz']));
for($i = strtotime($day, $start->getTimestamp()); $i <= $until->getTimestamp(); $i = strtotime('+1 week', $i)) { for ($i = strtotime($day, $start->getTimestamp()); $i <= $until->getTimestamp(); $i = strtotime('+1 week', $i)) {
if ($i >= $today) { if ($i >= $today) {
$eventStart = new \DateTime(); $eventStart = new \DateTime();
$eventStart->setTimestamp($i); $eventStart->setTimestamp($i);
@ -449,9 +450,9 @@ class DestinationDataImportService {
/** /**
* @param array $addresses * @param array $addresses
*/ */
protected function setOrganizer(Array $addresses) { protected function setOrganizer(array $addresses)
foreach ($addresses as $address) {
{ foreach ($addresses as $address) {
if ($address['rel'] == "organizer") { if ($address['rel'] == "organizer") {
$tmpOrganizer = $this->organizerRepository->findOneByName($address['name']); $tmpOrganizer = $this->organizerRepository->findOneByName($address['name']);
if ($tmpOrganizer) { if ($tmpOrganizer) {
@ -477,44 +478,55 @@ class DestinationDataImportService {
/** /**
* @param array $event * @param array $event
*/ */
protected function setAddress(Array $event) { protected function setAddress(array $event)
if (!empty($event['name'])) {
if (!empty($event['name'])) {
$this->tmpCurrentEvent->setName($event['name']); $this->tmpCurrentEvent->setName($event['name']);
if (!empty($event['street'])) }
if (!empty($event['street'])) {
$this->tmpCurrentEvent->setStreet($event['street']); $this->tmpCurrentEvent->setStreet($event['street']);
if (!empty($event['city'])) }
if (!empty($event['city'])) {
$this->tmpCurrentEvent->setCity($event['city']); $this->tmpCurrentEvent->setCity($event['city']);
if (!empty($event['zip'])) }
if (!empty($event['zip'])) {
$this->tmpCurrentEvent->setZip($event['zip']); $this->tmpCurrentEvent->setZip($event['zip']);
if (!empty($event['country'])) }
if (!empty($event['country'])) {
$this->tmpCurrentEvent->setCountry($event['country']); $this->tmpCurrentEvent->setCountry($event['country']);
if (!empty($event['phone'])) }
if (!empty($event['phone'])) {
$this->tmpCurrentEvent->setPhone($event['phone']); $this->tmpCurrentEvent->setPhone($event['phone']);
if (!empty($event['web'])) }
if (!empty($event['web'])) {
$this->tmpCurrentEvent->setWeb($event['web']); $this->tmpCurrentEvent->setWeb($event['web']);
}
/**
* @param array $media
*/
protected function setSocial(Array $media) {
foreach ($media as $link)
{
if ($link['rel'] == "socialmedia" && $link['value'] == "Facebook")
$this->tmpCurrentEvent->setFacebook($link['url']);
if ($link['rel'] == "socialmedia" && $link['value'] == "YouTube")
$this->tmpCurrentEvent->setYouTube($link['url']);
if ($link['rel'] == "socialmedia" && $link['value'] == "Instagram")
$this->tmpCurrentEvent->setInstagram($link['url']);
} }
} }
/** /**
* @param array $media * @param array $media
*/ */
protected function setTickets(Array $media) { protected function setSocial(array $media)
foreach ($media as $link) {
{ foreach ($media as $link) {
if ($link['rel'] == "socialmedia" && $link['value'] == "Facebook") {
$this->tmpCurrentEvent->setFacebook($link['url']);
}
if ($link['rel'] == "socialmedia" && $link['value'] == "YouTube") {
$this->tmpCurrentEvent->setYouTube($link['url']);
}
if ($link['rel'] == "socialmedia" && $link['value'] == "Instagram") {
$this->tmpCurrentEvent->setInstagram($link['url']);
}
}
}
/**
* @param array $media
*/
protected function setTickets(array $media)
{
foreach ($media as $link) {
if ($link['rel'] == "ticket") { if ($link['rel'] == "ticket") {
$this->tmpCurrentEvent->setTicket($link['url']); $this->tmpCurrentEvent->setTicket($link['url']);
break; break;
@ -531,14 +543,15 @@ class DestinationDataImportService {
* @param string $needle * @param string $needle
* @param array $haystack * @param array $haystack
*/ */
protected function multi_array_key_exists( $needle, $haystack ) { protected function multi_array_key_exists($needle, $haystack)
{
foreach ( $haystack as $key => $value ) { foreach ($haystack as $key => $value) {
if ( $needle == $key ) { if ($needle == $key) {
return true; return true;
} }
if ( is_array( $value ) ) { if (is_array($value)) {
if ( $this->multi_array_key_exists( $needle, $value ) == true ) { if ($this->multi_array_key_exists($needle, $value) == true) {
return true; return true;
} }
} }
@ -550,7 +563,8 @@ class DestinationDataImportService {
* @param string $lat * @param string $lat
* @param string $lng * @param string $lng
*/ */
protected function setLatLng(String $lat, String $lng) { protected function setLatLng(string $lat, string $lng)
{
$this->tmpCurrentEvent->setLatitude($lat); $this->tmpCurrentEvent->setLatitude($lat);
$this->tmpCurrentEvent->setLongitude($lng); $this->tmpCurrentEvent->setLongitude($lng);
} }
@ -559,9 +573,9 @@ class DestinationDataImportService {
* Set Texts * Set Texts
* @param Array $texts * @param Array $texts
*/ */
protected function setTexts(Array $texts) { protected function setTexts(array $texts)
foreach ($texts as $text) {
{ foreach ($texts as $text) {
if ($text['rel'] == "details" && $text['type'] == "text/plain") { if ($text['rel'] == "details" && $text['type'] == "text/plain") {
$this->tmpCurrentEvent->setDetails(str_replace('\n\n', '\n', $text['value'])); $this->tmpCurrentEvent->setDetails(str_replace('\n\n', '\n', $text['value']));
} }
@ -579,7 +593,8 @@ class DestinationDataImportService {
* @param String $globalId * @param String $globalId
* @param String $title * @param String $title
*/ */
protected function getOrCreateEvent(String $globalId, String $title) { protected function getOrCreateEvent(string $globalId, string $title)
{
$event = $this->eventRepository->findOneByGlobalId($globalId); $event = $this->eventRepository->findOneByGlobalId($globalId);
@ -605,16 +620,15 @@ class DestinationDataImportService {
/** /**
* @param array $assets * @param array $assets
*/ */
protected function setAssets(Array $assets) { protected function setAssets(array $assets)
{
$this->logger->info("Set assets"); $this->logger->info("Set assets");
$error = false; $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") {
$this->storage = $this->resourceFactory->getDefaultStorage(); $this->storage = $this->resourceFactory->getDefaultStorage();
$orgFileUrl = urldecode($media_object['url']); $orgFileUrl = urldecode($media_object['url']);
@ -656,10 +670,9 @@ class DestinationDataImportService {
$this->logger->info('No relation found'); $this->logger->info('No relation found');
$file = $this->storage->getFile($this->filesFolder . $orgFileNameSanitized); $file = $this->storage->getFile($this->filesFolder . $orgFileNameSanitized);
$this->metaDataRepository->update($file->getUid(), array('title' => $media_object['value'], 'description' => $media_object['description'], 'alternative' => 'DD Import')); $this->metaDataRepository->update($file->getUid(), array('title' => $media_object['value'], 'description' => $media_object['description'], 'alternative' => 'DD Import'));
$this->createFileRelations($file->getUid(), 'tx_events_domain_model_event', $this->tmpCurrentEvent->getUid(), 'images', $this->storagePid); $this->createFileRelations($file->getUid(), 'tx_events_domain_model_event', $this->tmpCurrentEvent->getUid(), 'images', $this->storagePid);
} }
} }
} }
$error = false; $error = false;
} }
@ -670,7 +683,8 @@ class DestinationDataImportService {
* @param string $file * @param string $file
* @return string * @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);
@ -692,7 +706,8 @@ class DestinationDataImportService {
* @param string $storagePid * @param string $storagePid
* @return bool * @return bool
*/ */
protected function createFileRelations($uid_local, $tablenames, $uid_foreign, $fieldname, $storagePid) { protected function createFileRelations($uid_local, $tablenames, $uid_foreign, $fieldname, $storagePid)
{
$newId = 'NEW1234'; $newId = 'NEW1234';
@ -719,7 +734,7 @@ class DestinationDataImportService {
return true; return true;
} }
foreach($dataHandler->errorLog as $error) { foreach ($dataHandler->errorLog as $error) {
$this->logger->info($error); $this->logger->info($error);
} }
return false; return false;

View file

@ -2,8 +2,10 @@
namespace Wrm\Events\ViewHelpers; namespace Wrm\Events\ViewHelpers;
class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper { class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper
protected function renderHiddenReferrerFields(){ {
protected function renderHiddenReferrerFields()
{
return ''; return '';
} }
} }

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Wrm\Events\Tests\Unit\Controller; namespace Wrm\Events\Tests\Unit\Controller;
/** /**

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Wrm\Events\Tests\Unit\Controller; namespace Wrm\Events\Tests\Unit\Controller;
/** /**

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Wrm\Events\Tests\Unit\Controller; namespace Wrm\Events\Tests\Unit\Controller;
/** /**

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Wrm\Events\Tests\Unit\Domain\Model; namespace Wrm\Events\Tests\Unit\Domain\Model;
/** /**

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Wrm\Events\Tests\Unit\Domain\Model; namespace Wrm\Events\Tests\Unit\Domain\Model;
/** /**

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Wrm\Events\Tests\Unit\Domain\Model; namespace Wrm\Events\Tests\Unit\Domain\Model;
/** /**

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Wrm\Events\Tests\Unit\Domain\Model; namespace Wrm\Events\Tests\Unit\Domain\Model;
/** /**

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Wrm\Events\Tests\Unit\Domain\Model; namespace Wrm\Events\Tests\Unit\Domain\Model;
/** /**

View file

@ -27,5 +27,8 @@
"typo3/cms": { "typo3/cms": {
"extension-key": "events" "extension-key": "events"
} }
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5"
} }
} }

View file

@ -1,9 +1,9 @@
<?php <?php
defined('TYPO3') || die('Access denied.'); defined('TYPO3') || die('Access denied.');
call_user_func( call_user_func(
function() function () {
{
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Events', 'Events',

View file

@ -1,9 +1,9 @@
<?php <?php
defined('TYPO3') || die('Access denied.'); defined('TYPO3') || die('Access denied.');
call_user_func( call_user_func(
function() function () {
{
/* /*
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
@ -27,6 +27,5 @@ call_user_func(
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_events_domain_model_region', 'EXT:events/Resources/Private/Language/locallang_csh_tx_events_domain_model_region.xlf'); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_events_domain_model_region', 'EXT:events/Resources/Private/Language/locallang_csh_tx_events_domain_model_region.xlf');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_events_domain_model_region'); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_events_domain_model_region');
} }
); );

21
phpcs.xml.dist Normal file
View file

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<ruleset name="project">
<description>This project coding standard</description>
<file>Classes/</file>
<file>Tests/</file>
<file>ext_localconf.php</file>
<file>ext_tables.php</file>
<!-- Set default settings -->
<arg value="sp"/>
<arg name="colors"/>
<arg name="encoding" value="utf-8" />
<arg name="extensions" value="php" />
<!-- Base rules -->
<rule ref="PSR12" />
<rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>/Tests/*</exclude-pattern>
</rule>
</ruleset>