Skip to content

Commit

Permalink
[TASK] Ensure base compatibility with TYPO3 13 (PHP and Fluid, not JS…
Browse files Browse the repository at this point in the history
…), references #350
  • Loading branch information
fsuter committed Dec 31, 2024
1 parent 447f416 commit 7af2027
Show file tree
Hide file tree
Showing 27 changed files with 213 additions and 186 deletions.
10 changes: 6 additions & 4 deletions Classes/Command/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down Expand Up @@ -120,6 +121,7 @@ public function configure()
protected function execute(InputInterface $input, OutputInterface $output): int
{
// Make sure the _cli_ user is loaded
Bootstrap::initializeBackendUser(CommandLineUserAuthentication::class);
Bootstrap::initializeBackendAuthentication();

$this->io = new SymfonyStyle($input, $output);
Expand Down Expand Up @@ -271,13 +273,13 @@ protected function reportResults(array $messages): void
foreach ($messages as $severity => $messageList) {
foreach ($messageList as $message) {
switch ($severity) {
case AbstractMessage::ERROR:
case ContextualFeedbackSeverity::ERROR->value:
$this->io->error($message);
break;
case AbstractMessage::WARNING:
case ContextualFeedbackSeverity::WARNING->value:
$this->io->warning($message);
break;
case AbstractMessage::OK:
case ContextualFeedbackSeverity::OK->value:
$this->io->success($message);
}
}
Expand Down
52 changes: 24 additions & 28 deletions Classes/Controller/DataModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
Expand Down Expand Up @@ -97,7 +97,7 @@ public function listSynchronizableAction(): ResponseInterface
'external_import'
),
'',
AbstractMessage::INFO
ContextualFeedbackSeverity::INFO
);
} catch (\Exception $e) {
// The above code should really work, nothing to do if it doesn't
Expand All @@ -109,7 +109,7 @@ public function listSynchronizableAction(): ResponseInterface
} catch (\Exception $e) {
$fullSynchronizationTask = null;
}
$this->view->assignMultiple(
$this->moduleTemplate->assignMultiple(
[
'configurations' => $configurations,
'fullSynchronizationTask' => $fullSynchronizationTask,
Expand All @@ -126,8 +126,7 @@ public function listSynchronizableAction(): ResponseInterface
]
);

$this->moduleTemplate->setContent($this->view->render());
return $this->htmlResponse($this->moduleTemplate->renderContent());
return $this->moduleTemplate->renderResponse('DataModule/ListSynchronizable');
}

/**
Expand All @@ -149,20 +148,19 @@ public function listNonSynchronizableAction(): ResponseInterface
'external_import'
),
'',
AbstractMessage::INFO
ContextualFeedbackSeverity::INFO
);
} catch (\Exception $e) {
// The above code should really work, nothing to do if it doesn't
}
}
$this->view->assignMultiple(
$this->moduleTemplate->assignMultiple(
[
'configurations' => $configurations,
]
);

$this->moduleTemplate->setContent($this->view->render());
return $this->htmlResponse($this->moduleTemplate->renderContent());
return $this->moduleTemplate->renderResponse('DataModule/ListNonSynchronizable');
}

/**
Expand Down Expand Up @@ -233,10 +231,10 @@ public function previewAction(string $table, string $index, string $stepClass =
]
),
'',
AbstractMessage::ERROR
ContextualFeedbackSeverity::ERROR
);
}
$this->view->assignMultiple(
$this->moduleTemplate->assignMultiple(
[
'table' => $table,
'index' => $index,
Expand All @@ -247,8 +245,7 @@ public function previewAction(string $table, string $index, string $stepClass =
]
);

$this->moduleTemplate->setContent($this->view->render());
return $this->htmlResponse($this->moduleTemplate->renderContent());
return $this->moduleTemplate->renderResponse('DataModule/Preview');
}

/**
Expand Down Expand Up @@ -292,7 +289,7 @@ public function downloadPreviewAction(string $table, string $index, string $step
]
),
'',
AbstractMessage::ERROR
ContextualFeedbackSeverity::ERROR
);
return $this->redirect(
'preview',
Expand Down Expand Up @@ -351,7 +348,7 @@ public function viewConfigurationAction(string $table, string $index): ResponseI
]
),
'',
AbstractMessage::ERROR
ContextualFeedbackSeverity::ERROR
);
}

Expand All @@ -364,7 +361,7 @@ public function viewConfigurationAction(string $table, string $index): ResponseI
// Add a close button to the toolbar
$this->prepareView('', $returnAction);

$this->view->assignMultiple(
$this->moduleTemplate->assignMultiple(
[
'table' => $table,
'index' => $index,
Expand All @@ -373,8 +370,7 @@ public function viewConfigurationAction(string $table, string $index): ResponseI
],
);

$this->moduleTemplate->setContent($this->view->render());
return $this->htmlResponse($this->moduleTemplate->renderContent());
return $this->moduleTemplate->renderResponse('DataModule/ViewConfiguration');
}

/**
Expand All @@ -388,7 +384,7 @@ public function newTaskAction(string $table, string $index = ''): ResponseInterf
{
// Add a close button to the toolbar
$this->prepareView('', 'listSynchronizable');
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DateTimePicker');
// $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DateTimePicker');

$this->view->assignMultiple(
[
Expand All @@ -398,8 +394,7 @@ public function newTaskAction(string $table, string $index = ''): ResponseInterf
]
);

$this->moduleTemplate->setContent($this->view->render());
return $this->htmlResponse($this->moduleTemplate->renderContent());
return $this->moduleTemplate->renderResponse('DataModule/NewTask');
}

/**
Expand Down Expand Up @@ -443,7 +438,7 @@ public function createTaskAction(
]
),
'',
AbstractMessage::ERROR
ContextualFeedbackSeverity::ERROR
);
}
return $this->redirect('listSynchronizable');
Expand Down Expand Up @@ -476,13 +471,12 @@ public function editTaskAction(int $uid): ResponseInterface
'external_import'
),
'',
AbstractMessage::ERROR
ContextualFeedbackSeverity::ERROR
);
return $this->redirect('listSynchronizable');
}

$this->moduleTemplate->setContent($this->view->render());
return $this->htmlResponse($this->moduleTemplate->renderContent());
return $this->moduleTemplate->renderResponse('DataModule/EditTask');
}

/**
Expand Down Expand Up @@ -522,7 +516,7 @@ public function updateTaskAction(int $uid, string $frequency, int $group): Respo
]
),
'',
AbstractMessage::ERROR
ContextualFeedbackSeverity::ERROR
);
}
return $this->redirect('listSynchronizable');
Expand Down Expand Up @@ -554,7 +548,7 @@ public function deleteTaskAction(int $uid): ResponseInterface
]
),
'',
AbstractMessage::ERROR
ContextualFeedbackSeverity::ERROR
);
}
return $this->redirect('listSynchronizable');
Expand Down Expand Up @@ -590,6 +584,7 @@ protected function loadResources(): void
ExtensionManagementUtility::extPath('external_import') . 'Resources/Public/'
);
$this->pageRenderer->addCssFile($publicResourcesPath . 'StyleSheet/ExternalImport.css');
/*
$this->pageRenderer->addRequireJsConfiguration(
[
'paths' => [
Expand All @@ -598,6 +593,7 @@ protected function loadResources(): void
]
);
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/ExternalImport/DataModule');
*/
$this->pageRenderer->addInlineLanguageLabelFile('EXT:external_import/Resources/Private/Language/JavaScript.xlf');

// Evaluate write access on all tables
Expand Down Expand Up @@ -680,7 +676,7 @@ protected function prepareMessages(array $messages, bool $storeInSession = true)
$this->addFlashMessage(
$aMessage,
'',
$severity,
ContextualFeedbackSeverity::tryFrom($severity),
$storeInSession
);
} catch (\Exception $e) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function getGeneralConfiguration(): array
* @param array $generalConfiguration
* @param array|null $defaultSteps List of default steps (if null will be guessed by the repository)
*/
public function setGeneralConfiguration(array $generalConfiguration, ?array $defaultSteps): void
public function setGeneralConfiguration(array $generalConfiguration, ?array $defaultSteps = null): void
{
$this->generalConfiguration = $generalConfiguration;
$stepUtility = GeneralUtility::makeInstance(StepUtility::class);
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Model/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;

/**
Expand All @@ -28,7 +28,7 @@ class Log extends AbstractEntity
/**
* @var int Run status (based on FlashMessage codes)
*/
protected int $status = AbstractMessage::NOTICE;
protected int $status = ContextualFeedbackSeverity::NOTICE->value;

/**
* @var \DateTime|null Run date and time
Expand Down
13 changes: 8 additions & 5 deletions Classes/Domain/Repository/ChildrenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace Cobweb\ExternalImport\Domain\Repository;

use Cobweb\ExternalImport\Exception\NoSuchRecordException;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
Expand All @@ -29,33 +30,35 @@
class ChildrenRepository
{
/**
* Returns all existing records in the given table for the given condition.
* Return all existing records in the given table for the given condition.
*
* @param string $table Table to query
* @param array $conditions Conditions to apply (field-value pairs)
* @return array
* @throws \Doctrine\DBAL\Exception
*/
public function findAllExistingRecords(string $table, array $conditions): array
{
$existingRecords = [];
$queryBuilder = $this->prepareQueryBuilder($table, $conditions);
$result = $queryBuilder->executeQuery();
while ($record = $result->fetch()) {
while ($record = $result->fetchAssociative()) {
$existingRecords[] = $record['uid'];
}
return $existingRecords;
}

/**
* Returns the first existing records in the given table for the given condition.
* Return the first existing records in the given table for the given condition.
*
* NOTE: it is assumed that the given conditions lead to a single record being found.
* We don't consider other records if that is not the case.
*
* @param string $table Table to query
* @param array $conditions Conditions to apply (field-value pairs)
* @return int
* @throws \Cobweb\ExternalImport\Exception\NoSuchRecordException
* @throws NoSuchRecordException
* @throws \Doctrine\DBAL\Exception
*/
public function findFirstExistingRecord(string $table, array $conditions): int
{
Expand All @@ -65,7 +68,7 @@ public function findFirstExistingRecord(string $table, array $conditions): int
if ($record) {
return (int)$record['uid'];
}
throw new \Cobweb\ExternalImport\Exception\NoSuchRecordException(
throw new NoSuchRecordException(
'Record not found with the given conditions',
1602322832
);
Expand Down
9 changes: 2 additions & 7 deletions Classes/Domain/Repository/ConfigurationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ class ConfigurationRepository
/**
* @var array Extension configuration
*/
protected $extensionConfiguration = [];

public function __toString()
{
return self::class;
}
protected array $extensionConfiguration = [];

/**
* ConfigurationRepository constructor.
Expand Down Expand Up @@ -216,7 +211,7 @@ public function findAllGroups(): array
* @return Configuration
* @throws \Cobweb\ExternalImport\Exception\NoConfigurationException
*/
public function findConfigurationObject(string $table, $index, ?array $defaultSteps): Configuration
public function findConfigurationObject(string $table, $index, ?array $defaultSteps = null): Configuration
{
$configuration = GeneralUtility::makeInstance(Configuration::class);
$externalConfiguration = $this->findByTableAndIndex($table, $index);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Repository/ItemRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class ItemRepository
* Find an item in the given DB table, matching one or more constraints
* (with strict equality), return its primary key (uid)
*
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Driver\Exception
* @throws InvalidRecordException
* @throws \Doctrine\DBAL\Exception
*/
public function find(string $table, array $constraints, string $additionalConstraint = ''): int
{
Expand Down
5 changes: 0 additions & 5 deletions Classes/Domain/Repository/LogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
*/
class LogRepository extends Repository
{
public function __toString()
{
return self::class;
}

public function initializeObject(): void
{
$querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class);
Expand Down
Loading

0 comments on commit 7af2027

Please sign in to comment.