Skip to content

Commit

Permalink
[TASK] Drop TYPO3 11 support in code
Browse files Browse the repository at this point in the history
  • Loading branch information
einpraegsam committed Oct 8, 2024
1 parent e1d7546 commit e5a2c2f
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 404 deletions.
10 changes: 1 addition & 9 deletions Classes/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,11 @@ public function __construct(
/**
* Pass some important variables to all views
*
* @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view (Todo: Param is only needed in TYPO3 11)
* @return void
* @throws ExtensionConfigurationExtensionNotConfiguredException
* @throws ExtensionConfigurationPathDoesNotExistException
*/
public function initializeView($view)
public function initializeView()
{
$this->view->assignMultiple([
'view' => [
Expand Down Expand Up @@ -191,13 +190,6 @@ protected function getActionName(): string
*/
protected function getRoute(): string
{
// Todo: Can be removed when TYPO3 11 support is dropped
if (ConfigurationUtility::isTypo3Version11()) {
/** @var Route $route */
$route = $this->request->getAttribute('route');
return $route->getOption('moduleName');
}

/** @var RouteResult $routeResult */
$routeResult = $this->request->getAttribute('routing');
/** @var ExtbaseModule $extbaseModule */
Expand Down
5 changes: 2 additions & 3 deletions Classes/Controller/LeadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use Psr\Http\Message\ServerRequestInterface;
use Throwable;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException;
use TYPO3\CMS\Extbase\Http\ForwardResponse;
Expand Down Expand Up @@ -241,8 +241,7 @@ public function companiesDisabledAction(string $tokenWiredminds = ''): ResponseI
$companyConfigurationService->add($tokenWiredminds);
$this->addFlashMessage(LocalizationUtility::translateByKey('module.companiesDisabled.token.success'));
} catch (Throwable $exception) {
// Todo: AbstractMessage::ERROR can be replaced with ContextualFeedbackSeverity::ERROR when TYPO3 11 support is dropped
$this->addFlashMessage($exception->getMessage(), '', AbstractMessage::ERROR);
$this->addFlashMessage($exception->getMessage(), '', ContextualFeedbackSeverity::ERROR);
}
return $this->redirect('companies');
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/DataProvider/AbstractDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getData(): array

public function getTitlesFromData(): array
{
$titles = (array)$this->getData()['titles'];
$titles = $this->getData()['titles'] ?? [];
if ($this->cropTitles > 0) {
$titles = ArrayUtility::cropStringInArray($titles, $this->cropTitles);
}
Expand Down
10 changes: 4 additions & 6 deletions Classes/Domain/Model/Visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,20 @@ class Visitor extends AbstractModel

/**
* @Lazy
* @var ?ObjectStorage<Fingerprint>
* @var ?Fingerprint|LazyLoadingProxy
* @phpstan-var ObjectStorage|LazyLoadingProxy|null
* Todo: Type can be changed to Fingerprint|LazyLoadingProxy|null when PHP 7.4 is dropped
*/
protected ?object $fingerprints = null;
protected Fingerprint|LazyLoadingProxy|null $fingerprints = null;

protected string $email = '';
protected string $company = '';

/**
* @Lazy
* @var Company|null
* @var Company|LazyLoadingProxy|null
* @phpstan-var Company|LazyLoadingProxy|null
* Todo: Type can be changed to Company|LazyLoadingProxy|null when PHP 7.4 is dropped
*/
protected ?object $companyrecord = null;
protected Company|LazyLoadingProxy|null $companyrecord = null;

protected bool $identified = false;

Expand Down
23 changes: 0 additions & 23 deletions Classes/Hooks/PageOverview.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public function __construct(
}

/**
* Called from PSR-14 for TYPO3 12
*
* @param ModifyPageLayoutContentEvent $event
* @return void
* @throws ConfigurationException
Expand All @@ -74,27 +72,6 @@ public function eventRegistration(ModifyPageLayoutContentEvent $event): void
$event->addHeaderContent($this->renderContent($pageIdentifier));
}

/**
* Called from ext_localconf.php for TYPO3 11
* Todo: Can be removed when TYPO3 11 support is dropped
*
* @param array $parameters
* @param PageLayoutController $plController
* @return string
* @throws ConfigurationException
* @throws ExceptionDbal
* @throws ExtensionConfigurationExtensionNotConfiguredException
* @throws ExtensionConfigurationPathDoesNotExistException
* @throws UnexpectedValueException
* @throws ExceptionDbalDriver
* @throws DBALException
*/
public function render(array $parameters, PageLayoutController $plController): string
{
unset($parameters);
return $this->renderContent($plController->id);
}

/**
* @param int $pageIdentifier
* @return string
Expand Down
30 changes: 0 additions & 30 deletions Classes/Utility/ConfigurationUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;

class ConfigurationUtility
{
Expand Down Expand Up @@ -236,33 +235,4 @@ protected static function getExtensionConfiguration(): array
{
return GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('lux');
}

/**
* Todo: Can be removed if TYPO3 11 support is dropped
*
* @return bool
*/
public static function isTypo3Version11(): bool
{
return self::isVersionToCompareSameOrHigherThenCurrentTypo3Version('11.5.99');
}

/**
* @param string $versionToCompare like "1.2.3"
* @return bool
*/
public static function isVersionToCompareSameOrHigherThenCurrentTypo3Version(string $versionToCompare): bool
{
return VersionNumberUtility::convertVersionNumberToInteger($versionToCompare) >= self::getCurrentTypo3Version();
}

/**
* Return current TYPO3 version as integer - e.g. 10003000 (10.3.0) or 9005014 (9.5.14)
*
* @return int
*/
protected static function getCurrentTypo3Version(): int
{
return VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getNumericTypo3Version());
}
}
4 changes: 2 additions & 2 deletions Classes/Utility/DatabaseUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function isTableExisting(string $tableName): bool
{
$existing = false;
$connection = self::getConnectionForTable($tableName);
$queryResult = $connection->query('show tables;')->fetchAll();
$queryResult = $connection->executeQuery('show tables;')->fetchAllAssociative();
foreach ($queryResult as $tableProperties) {
if (in_array($tableName, array_values($tableProperties))) {
$existing = true;
Expand All @@ -55,7 +55,7 @@ public static function isFieldExistingInTable(string $fieldName, string $tableNa
{
$found = false;
$connection = self::getConnectionForTable($tableName);
$queryResult = $connection->query('describe ' . $tableName . ';')->fetchAll();
$queryResult = $connection->executeQuery('describe ' . $tableName . ';')->fetchAllAssociative();
foreach ($queryResult as $fieldProperties) {
if ($fieldProperties['Field'] === $fieldName) {
$found = true;
Expand Down
25 changes: 0 additions & 25 deletions Classes/ViewHelpers/Condition/IsTypo3ElevenViewHelper.php

This file was deleted.

4 changes: 0 additions & 4 deletions Classes/ViewHelpers/Pagination/UriViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ public function render(): string
$extensionService = GeneralUtility::makeInstance(ExtensionService::class);
$pluginNamespace = $extensionService->getPluginNamespace($extensionName, $pluginName);
$argumentPrefix = $pluginNamespace . '[' . $this->arguments['name'] . ']';
if (ConfigurationUtility::isTypo3Version11()) {
// Todo: Can be removed in TYPO3 11 support is dropped
$argumentPrefix = $this->arguments['name'];
}
$arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : [];
if ($this->hasArgument('action')) {
$arguments['action'] = $this->arguments['action'];
Expand Down
Loading

0 comments on commit e5a2c2f

Please sign in to comment.