Skip to content

Commit

Permalink
First migration for TYPO3 v12
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Mar 21, 2024
1 parent e32f938 commit f3bd8cf
Show file tree
Hide file tree
Showing 25 changed files with 101 additions and 304 deletions.
19 changes: 2 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,9 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["7.2", "7.3", "7.4"]
typo3: ["^10.4"]
php: ["8.1", "8.2"]
typo3: ["^12.4"]
continue-on-error: [false]
include:
- php: "7.4"
coverage: "1"
- php: "8.0"
typo3: "^10.4"
continue-on-error: true
- php: "7.4"
typo3: "^11.5"
continue-on-error: false
- php: "8.0"
typo3: "^11.5"
continue-on-error: false
- php: "8.1"
typo3: "^11.5"
continue-on-error: false
continue-on-error: ${{ matrix.continue-on-error }}
env:
TYPO3_VERSION: ${{ matrix.typo3 }}
Expand Down
16 changes: 4 additions & 12 deletions Classes/Command/ImportCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;

/**
* ImportCommandController
*
Expand All @@ -23,20 +22,13 @@
class ImportCommandController extends Command
{

/**
* @var object|\Psr\Log\LoggerAwareInterface|\TYPO3\CMS\Core\SingletonInterface|ObjectManager
*/
protected $objectManager;

/**
* ImportCommandController constructor.
* @param string|null $name
*/
public function __construct(string $name = null)
{
parent::__construct($name);

$this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
}

/**
Expand Down Expand Up @@ -64,11 +56,11 @@ public function initializeServiceManagerCommand($mail = null)
FlashMessage::class,
'',
'Initializing ServiceManager',
FlashMessage::INFO
\TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO
);
$this->addFlashMessage($message);

$manager = $this->objectManager->get(Manager::class);
$manager = GeneralUtility::makeInstance(Manager::class);
try {
// let the manager run the imports now
$manager->runImports();
Expand All @@ -77,7 +69,7 @@ public function initializeServiceManagerCommand($mail = null)
FlashMessage::class,
'',
'An Error occured: ' . $e->getCode() . ': ' . $e->getMessage(),
FlashMessage::ERROR
\TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::ERROR
);
$this->addFlashMessage($message);

Expand Down
21 changes: 13 additions & 8 deletions Classes/Controller/ImportrController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use HDNET\Importr\Domain\Repository\StrategyRepository;
use HDNET\Importr\Service\ImportServiceInterface;
use HDNET\Importr\Service\Manager;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Resource\ResourceFactory;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function __construct(
$this->importService = $importService;
}

public function indexAction()
public function indexAction():ResponseInterface
{
$combinedIdentifier = GeneralUtility::_GP('id');
if (isset($combinedIdentifier) && \is_string($combinedIdentifier)) {
Expand All @@ -75,37 +76,41 @@ public function indexAction()
$this->view->assign('folder', $files);
}
$this->view->assign('imports', $this->importRepository->findUserQueue());

return $this->htmlResponse($this->view->render());
}

/**
* @param string $identifier
*/
public function importAction($identifier)
public function importAction($identifier):ResponseInterface
{
$file = $this->resourceFactory->getObjectFromCombinedIdentifier($identifier);
$this->view->assign('file', $file);
$this->view->assign('strategies', $this->strategyRepository->findAllUser());
return $this->htmlResponse($this->view->render());
}

/**
* @param string $identifier
* @param \HDNET\Importr\Domain\Model\Strategy $strategy
*/
public function previewAction($identifier, Strategy $strategy)
public function previewAction($identifier, Strategy $strategy):ResponseInterface
{
$file = $this->resourceFactory->getObjectFromCombinedIdentifier($identifier);
$this->view->assign('filepath', $file->getPublicUrl());
$this->view->assign('strategy', $strategy);

$previewData = $this->importManager->getPreview($strategy, $file->getPublicUrl());
$this->view->assign('preview', $previewData);
return $this->htmlResponse($this->view->render());
}

/**
* @param string $filepath
* @param \HDNET\Importr\Domain\Model\Strategy $strategy
*/
public function createAction($filepath, Strategy $strategy)
public function createAction($filepath, Strategy $strategy):ResponseInterface
{
$this->importService->addToQueue($filepath, $strategy);
$text = 'The Import file %s width the strategy %s was successfully added to the queue';
Expand All @@ -117,22 +122,22 @@ public function createAction($filepath, Strategy $strategy)
true
);

$flashMessageService = $this->objectManager->get(
$flashMessageService = GeneralUtility::makeInstance(
FlashMessageService::class
);
$messageQueue = $flashMessageService->getMessageQueueByIdentifier();
$messageQueue->addMessage($message);

$this->redirect('index');
return $this->redirect('index');
}

/**
* @param Import $import
*/
public function resetAction(Import $import)
public function resetAction(Import $import):ResponseInterface
{
$import->reset();
$this->importRepository->update($import);
$this->redirect('index');
return $this->redirect('index');
}
}
4 changes: 2 additions & 2 deletions Classes/Domain/Repository/ImportRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function findUserQueue($days = 7)
$query->greaterThan('starttime', \time() - 60 * 60 * 24 * $days)
];

$query->matching($query->logicalAnd($conditions));
$query->matching($query->logicalAnd(...$conditions));

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

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

$query->matching($query->logicalAnd($conditions));
$query->matching($query->logicalAnd(...$conditions));

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

Expand Down
5 changes: 2 additions & 3 deletions Classes/Feature/FeatureRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

use HDNET\Importr\Service\Manager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;

/**
* Class FeatureRegistry
Expand All @@ -21,7 +20,6 @@ class FeatureRegistry
*/
public static function enable($names, $class = Manager::class)
{
$dispatcher = GeneralUtility::makeInstance(Dispatcher::class);
if (!\is_array($names)) {
$names = [$names];
}
Expand All @@ -30,7 +28,8 @@ public static function enable($names, $class = Manager::class)
$caller = $trace[1]['class'];

foreach ($names as $name) {
$dispatcher->connect($class, $name, $caller, 'execute');
// @todo migrate to events
// $dispatcher->connect($class, $name, $caller, 'execute');
}
}
}
22 changes: 9 additions & 13 deletions Classes/Processor/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@
use HDNET\Importr\Exception\ReinitializeException;
use HDNET\Importr\Service\ImportServiceInterface;
use HDNET\Importr\Service\ManagerInterface;
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
use Psr\EventDispatcher\EventDispatcherInterface;

/**
* Configuration
*/
class Configuration
{
/**
* @var Dispatcher
*/
protected $dispatcher;

/**
* @var StrategyRepository
Expand All @@ -34,13 +30,11 @@ class Configuration
/**
* Configuration constructor.
*
* @param Dispatcher $dispatcher
* @param StrategyRepository $strategyRepository
* @param ImportServiceInterface $importService
*/
public function __construct(Dispatcher $dispatcher, StrategyRepository $strategyRepository, ImportServiceInterface $importService)
public function __construct(protected EventDispatcherInterface $eventDispatcher, StrategyRepository $strategyRepository, ImportServiceInterface $importService)
{
$this->dispatcher = $dispatcher;
$this->strategyRepository = $strategyRepository;
$this->importService = $importService;
}
Expand Down Expand Up @@ -106,11 +100,13 @@ protected function processInner(array $configuration, ManagerInterface $manager)
*/
protected function emitSignal($name, array &$configuration)
{
$this->dispatcher->dispatch(
__CLASS__,
$name,
[$this, $configuration]
);

// @todo migrate to events
#$this->dispatcher->dispatch(
# __CLASS__,
# $name,
# [$this, $configuration]
#);
}

/**
Expand Down
22 changes: 8 additions & 14 deletions Classes/Processor/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use HDNET\Importr\Domain\Model\Import;
use HDNET\Importr\Service\ImportServiceInterface;
use HDNET\Importr\Service\Targets\TargetInterface;
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
use Psr\EventDispatcher\EventDispatcherInterface;

/**
* Target
Expand All @@ -19,21 +19,14 @@ class Target
*/
protected $importService;

/**
* @var Dispatcher
*/
protected $dispatcher;

/**
* Target constructor.
*
* @param ImportServiceInterface $importService
* @param Dispatcher $dispatcher
*/
public function __construct(ImportServiceInterface $importService, Dispatcher $dispatcher)
public function __construct(ImportServiceInterface $importService, protected EventDispatcherInterface $dispatcher)
{
$this->importService = $importService;
$this->dispatcher = $dispatcher;
}

/**
Expand Down Expand Up @@ -66,11 +59,12 @@ public function process(TargetInterface $target, $entry, Import $import, $pointe
*/
protected function emitEntrySignal($name, array $configuration, $entry)
{
$result = $this->dispatcher->dispatch(
__CLASS__,
$name,
[$configuration, $entry]
);
// @todo migrate to events
#$result = $this->dispatcher->dispatch(
# __CLASS__,
# $name,
# [$configuration, $entry]
#);

return $result[1];
}
Expand Down
6 changes: 1 addition & 5 deletions Classes/Service/DatabaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ class DatabaseService
*/
public function getDatabaseConnection()
{
if (VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getNumericTypo3Version()) > 9005000) {
return GeneralUtility::makeInstance(DatabaseConnection::class);
}

return $GLOBALS['TYPO3_DB'];
return GeneralUtility::makeInstance(DatabaseConnection::class);
}
}
12 changes: 3 additions & 9 deletions Classes/Service/ImportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use HDNET\Importr\Domain\Model\Import;
use HDNET\Importr\Domain\Model\Strategy;
use HDNET\Importr\Domain\Repository\ImportRepository;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface;

/**
Expand All @@ -20,10 +20,6 @@ class ImportService implements ImportServiceInterface
*/
protected $persistenceManager;

/**
* @var ObjectManagerInterface
*/
protected $objectManager;

/**
* @var ImportRepository
Expand All @@ -34,13 +30,11 @@ class ImportService implements ImportServiceInterface
* ImportService constructor.
*
* @param PersistenceManagerInterface $persistenceManager
* @param ObjectManagerInterface $objectManager
* @param ImportRepository $importRepository
*/
public function __construct(PersistenceManagerInterface $persistenceManager, ObjectManagerInterface $objectManager, ImportRepository $importRepository)
public function __construct(PersistenceManagerInterface $persistenceManager, ImportRepository $importRepository)
{
$this->persistenceManager = $persistenceManager;
$this->objectManager = $objectManager;
$this->importRepository = $importRepository;
}

Expand All @@ -64,7 +58,7 @@ public function updateImport(Import $import, $pointer = null)
*/
public function addToQueue($filepath, Strategy $strategy, array $configuration = [])
{
$import = $this->objectManager->get(Import::class);
$import = GeneralUtility::makeInstance(Import::class);
$start = 'now';
if (isset($configuration['start'])) {
$start = $configuration['start'];
Expand Down
Loading

0 comments on commit f3bd8cf

Please sign in to comment.