Skip to content

Commit f3bd8cf

Browse files
committed
First migration for TYPO3 v12
1 parent e32f938 commit f3bd8cf

25 files changed

+101
-304
lines changed

.github/workflows/test.yml

+2-17
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,9 @@ jobs:
66
strategy:
77
fail-fast: false
88
matrix:
9-
php: ["7.2", "7.3", "7.4"]
10-
typo3: ["^10.4"]
9+
php: ["8.1", "8.2"]
10+
typo3: ["^12.4"]
1111
continue-on-error: [false]
12-
include:
13-
- php: "7.4"
14-
coverage: "1"
15-
- php: "8.0"
16-
typo3: "^10.4"
17-
continue-on-error: true
18-
- php: "7.4"
19-
typo3: "^11.5"
20-
continue-on-error: false
21-
- php: "8.0"
22-
typo3: "^11.5"
23-
continue-on-error: false
24-
- php: "8.1"
25-
typo3: "^11.5"
26-
continue-on-error: false
2712
continue-on-error: ${{ matrix.continue-on-error }}
2813
env:
2914
TYPO3_VERSION: ${{ matrix.typo3 }}

Classes/Command/ImportCommandController.php

+4-12
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
use Symfony\Component\Console\Command\Command;
1111
use Symfony\Component\Console\Input\InputInterface;
1212
use Symfony\Component\Console\Output\OutputInterface;
13+
use TYPO3\CMS\Core\Messaging\AbstractMessage;
1314
use TYPO3\CMS\Core\Messaging\FlashMessage;
1415
use TYPO3\CMS\Core\Messaging\FlashMessageService;
1516
use TYPO3\CMS\Core\Utility\GeneralUtility;
16-
use TYPO3\CMS\Extbase\Object\ObjectManager;
17-
1817
/**
1918
* ImportCommandController
2019
*
@@ -23,20 +22,13 @@
2322
class ImportCommandController extends Command
2423
{
2524

26-
/**
27-
* @var object|\Psr\Log\LoggerAwareInterface|\TYPO3\CMS\Core\SingletonInterface|ObjectManager
28-
*/
29-
protected $objectManager;
30-
3125
/**
3226
* ImportCommandController constructor.
3327
* @param string|null $name
3428
*/
3529
public function __construct(string $name = null)
3630
{
3731
parent::__construct($name);
38-
39-
$this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
4032
}
4133

4234
/**
@@ -64,11 +56,11 @@ public function initializeServiceManagerCommand($mail = null)
6456
FlashMessage::class,
6557
'',
6658
'Initializing ServiceManager',
67-
FlashMessage::INFO
59+
\TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO
6860
);
6961
$this->addFlashMessage($message);
7062

71-
$manager = $this->objectManager->get(Manager::class);
63+
$manager = GeneralUtility::makeInstance(Manager::class);
7264
try {
7365
// let the manager run the imports now
7466
$manager->runImports();
@@ -77,7 +69,7 @@ public function initializeServiceManagerCommand($mail = null)
7769
FlashMessage::class,
7870
'',
7971
'An Error occured: ' . $e->getCode() . ': ' . $e->getMessage(),
80-
FlashMessage::ERROR
72+
\TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::ERROR
8173
);
8274
$this->addFlashMessage($message);
8375

Classes/Controller/ImportrController.php

+13-8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use HDNET\Importr\Domain\Repository\StrategyRepository;
1111
use HDNET\Importr\Service\ImportServiceInterface;
1212
use HDNET\Importr\Service\Manager;
13+
use Psr\Http\Message\ResponseInterface;
1314
use TYPO3\CMS\Core\Messaging\FlashMessage;
1415
use TYPO3\CMS\Core\Messaging\FlashMessageService;
1516
use TYPO3\CMS\Core\Resource\ResourceFactory;
@@ -62,7 +63,7 @@ public function __construct(
6263
$this->importService = $importService;
6364
}
6465

65-
public function indexAction()
66+
public function indexAction():ResponseInterface
6667
{
6768
$combinedIdentifier = GeneralUtility::_GP('id');
6869
if (isset($combinedIdentifier) && \is_string($combinedIdentifier)) {
@@ -75,37 +76,41 @@ public function indexAction()
7576
$this->view->assign('folder', $files);
7677
}
7778
$this->view->assign('imports', $this->importRepository->findUserQueue());
79+
80+
return $this->htmlResponse($this->view->render());
7881
}
7982

8083
/**
8184
* @param string $identifier
8285
*/
83-
public function importAction($identifier)
86+
public function importAction($identifier):ResponseInterface
8487
{
8588
$file = $this->resourceFactory->getObjectFromCombinedIdentifier($identifier);
8689
$this->view->assign('file', $file);
8790
$this->view->assign('strategies', $this->strategyRepository->findAllUser());
91+
return $this->htmlResponse($this->view->render());
8892
}
8993

9094
/**
9195
* @param string $identifier
9296
* @param \HDNET\Importr\Domain\Model\Strategy $strategy
9397
*/
94-
public function previewAction($identifier, Strategy $strategy)
98+
public function previewAction($identifier, Strategy $strategy):ResponseInterface
9599
{
96100
$file = $this->resourceFactory->getObjectFromCombinedIdentifier($identifier);
97101
$this->view->assign('filepath', $file->getPublicUrl());
98102
$this->view->assign('strategy', $strategy);
99103

100104
$previewData = $this->importManager->getPreview($strategy, $file->getPublicUrl());
101105
$this->view->assign('preview', $previewData);
106+
return $this->htmlResponse($this->view->render());
102107
}
103108

104109
/**
105110
* @param string $filepath
106111
* @param \HDNET\Importr\Domain\Model\Strategy $strategy
107112
*/
108-
public function createAction($filepath, Strategy $strategy)
113+
public function createAction($filepath, Strategy $strategy):ResponseInterface
109114
{
110115
$this->importService->addToQueue($filepath, $strategy);
111116
$text = 'The Import file %s width the strategy %s was successfully added to the queue';
@@ -117,22 +122,22 @@ public function createAction($filepath, Strategy $strategy)
117122
true
118123
);
119124

120-
$flashMessageService = $this->objectManager->get(
125+
$flashMessageService = GeneralUtility::makeInstance(
121126
FlashMessageService::class
122127
);
123128
$messageQueue = $flashMessageService->getMessageQueueByIdentifier();
124129
$messageQueue->addMessage($message);
125130

126-
$this->redirect('index');
131+
return $this->redirect('index');
127132
}
128133

129134
/**
130135
* @param Import $import
131136
*/
132-
public function resetAction(Import $import)
137+
public function resetAction(Import $import):ResponseInterface
133138
{
134139
$import->reset();
135140
$this->importRepository->update($import);
136-
$this->redirect('index');
141+
return $this->redirect('index');
137142
}
138143
}

Classes/Domain/Repository/ImportRepository.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function findUserQueue($days = 7)
3131
$query->greaterThan('starttime', \time() - 60 * 60 * 24 * $days)
3232
];
3333

34-
$query->matching($query->logicalAnd($conditions));
34+
$query->matching($query->logicalAnd(...$conditions));
3535

3636
$query->setOrderings(['starttime' => Query::ORDER_DESCENDING]);
3737

@@ -52,7 +52,7 @@ public function findWorkQueue()
5252
$query->lessThan('endtime', 1),
5353
];
5454

55-
$query->matching($query->logicalAnd($conditions));
55+
$query->matching($query->logicalAnd(...$conditions));
5656

5757
$query->setOrderings(['starttime' => Query::ORDER_ASCENDING]);
5858

Classes/Feature/FeatureRegistry.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
use HDNET\Importr\Service\Manager;
1010
use TYPO3\CMS\Core\Utility\GeneralUtility;
11-
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
1211

1312
/**
1413
* Class FeatureRegistry
@@ -21,7 +20,6 @@ class FeatureRegistry
2120
*/
2221
public static function enable($names, $class = Manager::class)
2322
{
24-
$dispatcher = GeneralUtility::makeInstance(Dispatcher::class);
2523
if (!\is_array($names)) {
2624
$names = [$names];
2725
}
@@ -30,7 +28,8 @@ public static function enable($names, $class = Manager::class)
3028
$caller = $trace[1]['class'];
3129

3230
foreach ($names as $name) {
33-
$dispatcher->connect($class, $name, $caller, 'execute');
31+
// @todo migrate to events
32+
// $dispatcher->connect($class, $name, $caller, 'execute');
3433
}
3534
}
3635
}

Classes/Processor/Configuration.php

+9-13
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,13 @@
99
use HDNET\Importr\Exception\ReinitializeException;
1010
use HDNET\Importr\Service\ImportServiceInterface;
1111
use HDNET\Importr\Service\ManagerInterface;
12-
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
12+
use Psr\EventDispatcher\EventDispatcherInterface;
1313

1414
/**
1515
* Configuration
1616
*/
1717
class Configuration
1818
{
19-
/**
20-
* @var Dispatcher
21-
*/
22-
protected $dispatcher;
2319

2420
/**
2521
* @var StrategyRepository
@@ -34,13 +30,11 @@ class Configuration
3430
/**
3531
* Configuration constructor.
3632
*
37-
* @param Dispatcher $dispatcher
3833
* @param StrategyRepository $strategyRepository
3934
* @param ImportServiceInterface $importService
4035
*/
41-
public function __construct(Dispatcher $dispatcher, StrategyRepository $strategyRepository, ImportServiceInterface $importService)
36+
public function __construct(protected EventDispatcherInterface $eventDispatcher, StrategyRepository $strategyRepository, ImportServiceInterface $importService)
4237
{
43-
$this->dispatcher = $dispatcher;
4438
$this->strategyRepository = $strategyRepository;
4539
$this->importService = $importService;
4640
}
@@ -106,11 +100,13 @@ protected function processInner(array $configuration, ManagerInterface $manager)
106100
*/
107101
protected function emitSignal($name, array &$configuration)
108102
{
109-
$this->dispatcher->dispatch(
110-
__CLASS__,
111-
$name,
112-
[$this, $configuration]
113-
);
103+
104+
// @todo migrate to events
105+
#$this->dispatcher->dispatch(
106+
# __CLASS__,
107+
# $name,
108+
# [$this, $configuration]
109+
#);
114110
}
115111

116112
/**

Classes/Processor/Target.php

+8-14
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use HDNET\Importr\Domain\Model\Import;
88
use HDNET\Importr\Service\ImportServiceInterface;
99
use HDNET\Importr\Service\Targets\TargetInterface;
10-
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
10+
use Psr\EventDispatcher\EventDispatcherInterface;
1111

1212
/**
1313
* Target
@@ -19,21 +19,14 @@ class Target
1919
*/
2020
protected $importService;
2121

22-
/**
23-
* @var Dispatcher
24-
*/
25-
protected $dispatcher;
26-
2722
/**
2823
* Target constructor.
2924
*
3025
* @param ImportServiceInterface $importService
31-
* @param Dispatcher $dispatcher
3226
*/
33-
public function __construct(ImportServiceInterface $importService, Dispatcher $dispatcher)
27+
public function __construct(ImportServiceInterface $importService, protected EventDispatcherInterface $dispatcher)
3428
{
3529
$this->importService = $importService;
36-
$this->dispatcher = $dispatcher;
3730
}
3831

3932
/**
@@ -66,11 +59,12 @@ public function process(TargetInterface $target, $entry, Import $import, $pointe
6659
*/
6760
protected function emitEntrySignal($name, array $configuration, $entry)
6861
{
69-
$result = $this->dispatcher->dispatch(
70-
__CLASS__,
71-
$name,
72-
[$configuration, $entry]
73-
);
62+
// @todo migrate to events
63+
#$result = $this->dispatcher->dispatch(
64+
# __CLASS__,
65+
# $name,
66+
# [$configuration, $entry]
67+
#);
7468

7569
return $result[1];
7670
}

Classes/Service/DatabaseService.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ class DatabaseService
2020
*/
2121
public function getDatabaseConnection()
2222
{
23-
if (VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getNumericTypo3Version()) > 9005000) {
24-
return GeneralUtility::makeInstance(DatabaseConnection::class);
25-
}
26-
27-
return $GLOBALS['TYPO3_DB'];
23+
return GeneralUtility::makeInstance(DatabaseConnection::class);
2824
}
2925
}

Classes/Service/ImportService.php

+3-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use HDNET\Importr\Domain\Model\Import;
88
use HDNET\Importr\Domain\Model\Strategy;
99
use HDNET\Importr\Domain\Repository\ImportRepository;
10-
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
10+
use TYPO3\CMS\Core\Utility\GeneralUtility;
1111
use TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface;
1212

1313
/**
@@ -20,10 +20,6 @@ class ImportService implements ImportServiceInterface
2020
*/
2121
protected $persistenceManager;
2222

23-
/**
24-
* @var ObjectManagerInterface
25-
*/
26-
protected $objectManager;
2723

2824
/**
2925
* @var ImportRepository
@@ -34,13 +30,11 @@ class ImportService implements ImportServiceInterface
3430
* ImportService constructor.
3531
*
3632
* @param PersistenceManagerInterface $persistenceManager
37-
* @param ObjectManagerInterface $objectManager
3833
* @param ImportRepository $importRepository
3934
*/
40-
public function __construct(PersistenceManagerInterface $persistenceManager, ObjectManagerInterface $objectManager, ImportRepository $importRepository)
35+
public function __construct(PersistenceManagerInterface $persistenceManager, ImportRepository $importRepository)
4136
{
4237
$this->persistenceManager = $persistenceManager;
43-
$this->objectManager = $objectManager;
4438
$this->importRepository = $importRepository;
4539
}
4640

@@ -64,7 +58,7 @@ public function updateImport(Import $import, $pointer = null)
6458
*/
6559
public function addToQueue($filepath, Strategy $strategy, array $configuration = [])
6660
{
67-
$import = $this->objectManager->get(Import::class);
61+
$import = GeneralUtility::makeInstance(Import::class);
6862
$start = 'now';
6963
if (isset($configuration['start'])) {
7064
$start = $configuration['start'];

0 commit comments

Comments
 (0)