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
namespace Wrm\Events\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
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
{
public function configure()
{
@ -31,12 +31,14 @@ class DestinationDataImportCommand extends Command {
'What is the region uid?',
'1'
);
$this->addArgument('rest-experience',
$this->addArgument(
'rest-experience',
InputArgument::OPTIONAL,
'What is the rest experience?',
'stadtmarketing-erfurt'
);
$this->addArgument('files-folder',
$this->addArgument(
'files-folder',
InputArgument::OPTIONAL,
'Where to save the image files?',
'staedte/erfurt/events/'
@ -56,4 +58,4 @@ class DestinationDataImportCommand extends Command {
$input->getArgument('files-folder')
);
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,9 @@
<?php
namespace Wrm\Events\Domain\Repository;
use TYPO3\CMS\Extbase\Persistence\Repository;
/**
* This file is part of the TYPO3 CMS project.
*
@ -20,4 +22,4 @@ use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
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\Database\ConnectionPool;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
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\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 DestinationDataImportService {
class DestinationDataImportService
{
/**
* @var
@ -210,7 +208,8 @@ class DestinationDataImportService {
* @param $regionUid
* @param $filesFolder
*/
public function import($restExperience, $storagePid, $regionUid, $filesFolder) {
public function import($restExperience, $storagePid, $regionUid, $filesFolder)
{
$this->restExperience = $restExperience;
$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;
$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');
return $this->processData($jsonResponse);
} else {
$this->logger->error('Could not receive data.');
return 1;
}
}
/**
* @param $data
* @return int
*/
public function processData($data) {
public function processData($data)
{
$this->logger->info('Processing json ' . count($data['items']));
@ -259,7 +258,6 @@ class DestinationDataImportService {
$selectedRegion = $this->regionRepository->findByUid($this->regionUid);
foreach ($data['items'] as $event) {
$this->logger->info('Processing event ' . substr($event['title'], 0, 20));
// Event already exists? If not create one!
@ -275,50 +273,59 @@ class DestinationDataImportService {
$this->tmpCurrentEvent->setTitle(substr($event['title'], 0, 254));
// Set Highlight (Is only set in rest if true)
if($event['highlight'])
if ($event['highlight']) {
$this->tmpCurrentEvent->setHighlight($event['highlight']);
}
// Set Texts
if($event['texts'])
if ($event['texts']) {
$this->setTexts($event['texts']);
}
// 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);
}
// 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']);
}
// Set Categories
if($event['categories'])
if ($event['categories']) {
$this->setCategories($event['categories']);
}
// Set Organizer
if($event['addresses'])
if ($event['addresses']) {
$this->setOrganizer($event['addresses']);
}
// Set Social
if($event['media_objects'])
if ($event['media_objects']) {
$this->setSocial($event['media_objects']);
}
// Set Tickets
if($event['media_objects'])
if ($event['media_objects']) {
$this->setTickets($event['media_objects']);
}
// Set Dates
if($event['timeIntervals'])
if ($event['timeIntervals']) {
$this->setDates($event['timeIntervals']);
}
// Set Assets
if($event['media_objects'])
if ($event['media_objects']) {
$this->setAssets($event['media_objects']);
}
// Update and persist
$this->logger->info('Persist database');
$this->eventRepository->update($this->tmpCurrentEvent);
$this->persistenceManager->persistAll();
}
$this->doSlugUpdate();
$this->logger->info('Finished import');
@ -329,7 +336,8 @@ class DestinationDataImportService {
*
* @param array $categories
*/
protected function setCategories(Array $categories) {
protected function setCategories(array $categories)
{
$sysParentCategory = $this->sysCategoriesRepository->findByUid($this->categoryParentUid);
foreach ($categories as $categoryTitle) {
$tmpSysCategory = $this->sysCategoriesRepository->findOneByTitle($categoryTitle);
@ -351,7 +359,8 @@ class DestinationDataImportService {
* @param array $timeIntervals
* @TODO: split into functions
*/
protected function setDates(Array $timeIntervals) {
protected function setDates(array $timeIntervals)
{
// @TODO: does not seem to work -->
//$currentEventDates = $this->tmpCurrentEvent->getDates();
@ -370,10 +379,8 @@ class DestinationDataImportService {
$today = $today->getTimestamp();
foreach ($timeIntervals as $date) {
// Check if dates are given as interval or not
if (empty($date['interval'])) {
if (strtotime($date['start']) > $today) {
$this->logger->info('Setup single date');
$dateObj = $this->objectManager->get(Date::class);
@ -387,18 +394,15 @@ class DestinationDataImportService {
$dateObj->setEnd($end);
$this->tmpCurrentEvent->addDate($dateObj);
}
} else {
if ($date['freq'] == 'Daily' && empty($date['weekdays']) && !empty($date['repeatUntil'])) {
$this->logger->info('Setup daily interval dates');
$this->logger->info('Start ' . $date['start']);
$this->logger->info('End ' . $date['repeatUntil']);
$start = new \DateTime($date['start'], 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) {
$eventStart = new \DateTime();
$eventStart->setTimestamp($i);
@ -413,10 +417,7 @@ class DestinationDataImportService {
$this->tmpCurrentEvent->addDate($dateObj);
}
}
}
else if ($date['freq'] == 'Weekly' && !empty($date['weekdays']) && !empty($date['repeatUntil'])) {
} elseif ($date['freq'] == 'Weekly' && !empty($date['weekdays']) && !empty($date['repeatUntil'])) {
foreach ($date['weekdays'] as $day) {
$this->logger->info('Setup weekly interval dates for ' . $day);
$this->logger->info('Start ' . $date['start']);
@ -424,7 +425,7 @@ class DestinationDataImportService {
$start = new \DateTime($date['start'], 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) {
$eventStart = new \DateTime();
$eventStart->setTimestamp($i);
@ -449,9 +450,9 @@ class DestinationDataImportService {
/**
* @param array $addresses
*/
protected function setOrganizer(Array $addresses) {
foreach ($addresses as $address)
{
protected function setOrganizer(array $addresses)
{
foreach ($addresses as $address) {
if ($address['rel'] == "organizer") {
$tmpOrganizer = $this->organizerRepository->findOneByName($address['name']);
if ($tmpOrganizer) {
@ -477,44 +478,55 @@ class DestinationDataImportService {
/**
* @param array $event
*/
protected function setAddress(Array $event) {
if (!empty($event['name']))
protected function setAddress(array $event)
{
if (!empty($event['name'])) {
$this->tmpCurrentEvent->setName($event['name']);
if (!empty($event['street']))
}
if (!empty($event['street'])) {
$this->tmpCurrentEvent->setStreet($event['street']);
if (!empty($event['city']))
}
if (!empty($event['city'])) {
$this->tmpCurrentEvent->setCity($event['city']);
if (!empty($event['zip']))
}
if (!empty($event['zip'])) {
$this->tmpCurrentEvent->setZip($event['zip']);
if (!empty($event['country']))
}
if (!empty($event['country'])) {
$this->tmpCurrentEvent->setCountry($event['country']);
if (!empty($event['phone']))
}
if (!empty($event['phone'])) {
$this->tmpCurrentEvent->setPhone($event['phone']);
if (!empty($event['web']))
}
if (!empty($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
*/
protected function setTickets(Array $media) {
foreach ($media as $link)
{
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
*/
protected function setTickets(array $media)
{
foreach ($media as $link) {
if ($link['rel'] == "ticket") {
$this->tmpCurrentEvent->setTicket($link['url']);
break;
@ -531,14 +543,15 @@ class DestinationDataImportService {
* @param string $needle
* @param array $haystack
*/
protected function multi_array_key_exists( $needle, $haystack ) {
protected function multi_array_key_exists($needle, $haystack)
{
foreach ( $haystack as $key => $value ) {
if ( $needle == $key ) {
foreach ($haystack as $key => $value) {
if ($needle == $key) {
return true;
}
if ( is_array( $value ) ) {
if ( $this->multi_array_key_exists( $needle, $value ) == true ) {
if (is_array($value)) {
if ($this->multi_array_key_exists($needle, $value) == true) {
return true;
}
}
@ -550,7 +563,8 @@ class DestinationDataImportService {
* @param string $lat
* @param string $lng
*/
protected function setLatLng(String $lat, String $lng) {
protected function setLatLng(string $lat, string $lng)
{
$this->tmpCurrentEvent->setLatitude($lat);
$this->tmpCurrentEvent->setLongitude($lng);
}
@ -559,9 +573,9 @@ class DestinationDataImportService {
* Set Texts
* @param Array $texts
*/
protected function setTexts(Array $texts) {
foreach ($texts as $text)
{
protected function setTexts(array $texts)
{
foreach ($texts as $text) {
if ($text['rel'] == "details" && $text['type'] == "text/plain") {
$this->tmpCurrentEvent->setDetails(str_replace('\n\n', '\n', $text['value']));
}
@ -579,7 +593,8 @@ class DestinationDataImportService {
* @param String $globalId
* @param String $title
*/
protected function getOrCreateEvent(String $globalId, String $title) {
protected function getOrCreateEvent(string $globalId, string $title)
{
$event = $this->eventRepository->findOneByGlobalId($globalId);
@ -605,16 +620,15 @@ class DestinationDataImportService {
/**
* @param array $assets
*/
protected function setAssets(Array $assets) {
protected function setAssets(array $assets)
{
$this->logger->info("Set assets");
$error = false;
foreach ($assets as $media_object)
{
if($media_object['rel'] == "default" && $media_object['type'] == "image/jpeg") {
foreach ($assets as $media_object) {
if ($media_object['rel'] == "default" && $media_object['type'] == "image/jpeg") {
$this->storage = $this->resourceFactory->getDefaultStorage();
$orgFileUrl = urldecode($media_object['url']);
@ -656,10 +670,9 @@ class DestinationDataImportService {
$this->logger->info('No relation found');
$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->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;
}
@ -670,7 +683,8 @@ class DestinationDataImportService {
* @param string $file
* @return string
*/
protected function loadFile($file) {
protected function loadFile($file)
{
$directory = $this->environment->getPublicPath() . "/uploads/tx_events/";
$filename = basename($file);
$this->logger->info('Getting file ' . $file . ' as ' . $filename);
@ -692,7 +706,8 @@ class DestinationDataImportService {
* @param string $storagePid
* @return bool
*/
protected function createFileRelations($uid_local, $tablenames, $uid_foreign, $fieldname, $storagePid) {
protected function createFileRelations($uid_local, $tablenames, $uid_foreign, $fieldname, $storagePid)
{
$newId = 'NEW1234';
@ -719,7 +734,7 @@ class DestinationDataImportService {
return true;
}
foreach($dataHandler->errorLog as $error) {
foreach ($dataHandler->errorLog as $error) {
$this->logger->info($error);
}
return false;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,9 @@
<?php
defined('TYPO3') || die('Access denied.');
call_user_func(
function()
{
function () {
/*
\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::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>