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/'

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;
@ -59,7 +60,6 @@ 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);
} }
/** /**
@ -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
@ -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.
@ -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.
@ -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.
* *

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.
* *

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;
@ -244,14 +243,14 @@ class DestinationDataImportService {
$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,11 +394,8 @@ 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']);
@ -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']);
@ -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 * @param array $media
*/ */
protected function setSocial(Array $media) { protected function setSocial(array $media)
foreach ($media as $link)
{ {
if ($link['rel'] == "socialmedia" && $link['value'] == "Facebook") foreach ($media as $link) {
if ($link['rel'] == "socialmedia" && $link['value'] == "Facebook") {
$this->tmpCurrentEvent->setFacebook($link['url']); $this->tmpCurrentEvent->setFacebook($link['url']);
if ($link['rel'] == "socialmedia" && $link['value'] == "YouTube") }
if ($link['rel'] == "socialmedia" && $link['value'] == "YouTube") {
$this->tmpCurrentEvent->setYouTube($link['url']); $this->tmpCurrentEvent->setYouTube($link['url']);
if ($link['rel'] == "socialmedia" && $link['value'] == "Instagram") }
if ($link['rel'] == "socialmedia" && $link['value'] == "Instagram") {
$this->tmpCurrentEvent->setInstagram($link['url']); $this->tmpCurrentEvent->setInstagram($link['url']);
} }
} }
}
/** /**
* @param array $media * @param array $media
*/ */
protected function setTickets(Array $media) { protected function setTickets(array $media)
foreach ($media as $link)
{ {
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,7 +543,8 @@ 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) {
@ -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']);
@ -659,7 +673,6 @@ class DestinationDataImportService {
$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';

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>