Skip to content

Commit

Permalink
[!!!][TASK] Added TYPO3 13.4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
derhansen committed Nov 1, 2024
1 parent 37ab8be commit a001e1f
Show file tree
Hide file tree
Showing 30 changed files with 289 additions and 503 deletions.
24 changes: 12 additions & 12 deletions .Build/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
],
"require": {
"derhansen/sf_banners": "@dev",
"typo3/cms-core": "^12.4",
"php": ">=8.1"
"typo3/cms-core": "^13.4",
"php": ">=8.2"
},
"require-dev": {
"typo3/cms-composer-installers": "^5.0",
"typo3/cms-backend": "^12.4",
"typo3/cms-frontend": "^12.4",
"typo3/cms-extbase": "^12.4",
"typo3/cms-felogin": "^12.4",
"typo3/cms-fluid-styled-content": "^12.4",
"typo3/cms-fluid": "^12.4",
"typo3/cms-tstemplate": "^12.4",
"typo3/cms-install": "^12.4",
"typo3/cms-extensionmanager": "^12.4",
"typo3/testing-framework": "^8.0",
"typo3/cms-backend": "^13.4",
"typo3/cms-frontend": "^13.4",
"typo3/cms-extbase": "^13.4",
"typo3/cms-felogin": "^13.4",
"typo3/cms-fluid-styled-content": "^13.4",
"typo3/cms-fluid": "^13.4",
"typo3/cms-tstemplate": "^13.4",
"typo3/cms-install": "^13.4",
"typo3/cms-extensionmanager": "^13.4",
"typo3/testing-framework": "^9.0",
"friendsofphp/php-cs-fixer": "^3.12.0",
"saschaegerer/phpstan-typo3": "^1.8.3",
"phpstan/extension-installer": "^1.1"
Expand Down
2 changes: 1 addition & 1 deletion .Build/php-cs-fixer/.php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
'single_line_empty_body' => false,
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
])
])
->setFinder(
PhpCsFixer\Finder::create()
->in(dirname(__DIR__ . '/../../../'))
Expand Down
1 change: 1 addition & 0 deletions .Build/phpunit/FunctionalTests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
failOnDeprecation="true"
beStrictAboutTestsThatDoNotTestAnything="false"
failOnWarning="true"
failOnRisky="true"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CodeQuality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
env:
- { php: 8.1, coverage: 0}
- { php: 8.2, coverage: 0}

env: ${{ matrix.env }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/UnitFunctionalTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.1', '8.2', '8.3']
php: ['8.2', '8.3', '8.4']

steps:
- uses: actions/checkout@v3
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: test documentation

on: [ push, pull_request ]

jobs:
tests:
name: documentation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Test if the documentation will render without warnings
run: |
mkdir -p Documentation-GENERATED-temp \
&& docker run --rm --pull always -v $(pwd):/project \
ghcr.io/typo3-documentation/render-guides:latest --config=Documentation --no-progress --fail-on-log
16 changes: 6 additions & 10 deletions Classes/Controller/BannerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Crypto\Random;
use TYPO3\CMS\Core\Http\PropagateResponseException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Frontend\Controller\ErrorController;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

class BannerController extends ActionController
{
public function __construct(
private readonly FrontendInterface $cacheInstance,
private readonly BannerRepository $bannerRepository
private readonly BannerRepository $bannerRepository,
private readonly Random $random
) {
}

Expand Down Expand Up @@ -56,7 +57,7 @@ public function clickAction(Banner $banner = null): ResponseInterface
public function showAction(): ResponseInterface
{
$languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');
$uniqueid = strtolower(substr(base64_encode(sha1(microtime())), 0, 9));
$uniqueid = strtolower($this->random->generateRandomHexString(10));

$arguments = [
'type' => $this->settings['ajaxPageTypeNum'],
Expand All @@ -82,7 +83,7 @@ public function showAction(): ResponseInterface
'maxResults' => ($this->settings['maxResults'] ?? '') !== '' ? (int)$this->settings['maxResults'] : 0,
];

$config = $this->hashService->appendHmac(json_encode($bannerConfig, JSON_THROW_ON_ERROR));
$config = $this->hashService->appendHmac(json_encode($bannerConfig, JSON_THROW_ON_ERROR), self::class);

$this->view->assignMultiple([
'fetchUrl' => $fetchUrl,
Expand All @@ -102,7 +103,7 @@ public function getBannersAction(array $bannerConfigs = []): ResponseInterface

foreach ($bannerConfigs as $bannerConfig) {
try {
$configString = $this->hashService->validateAndStripHmac($bannerConfig);
$configString = $this->hashService->validateAndStripHmac($bannerConfig, self::class);
$config = json_decode($configString, true, 512, JSON_THROW_ON_ERROR);
$result[] = [
'uniqueId' => $config['uniqueId'],
Expand Down Expand Up @@ -163,9 +164,4 @@ protected function getBannersByConfig(array $config): string

return $ret;
}

protected function getTypoScriptFrontendController(): ?TypoScriptFrontendController
{
return $GLOBALS['TSFE'] ?: null;
}
}
4 changes: 1 addition & 3 deletions Classes/Domain/Repository/BannerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ public function initializeObject(): void

/**
* Returns banners matching the given demand
*
* @return array|QueryResultInterface
*/
public function findDemanded(BannerDemand $demand)
public function findDemanded(BannerDemand $demand): array|QueryResultInterface
{
/* Override the default sorting for random mode. Must be called before createQuery() */
if ($demand->getDisplayMode() === 'allRandom') {
Expand Down
36 changes: 36 additions & 0 deletions Classes/Updates/PluginToContentElementUpdater.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Extension "sf_banners" for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/

namespace DERHANSEN\SfBanners\Updates;

use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\AbstractListTypeToCTypeUpdate;

#[UpgradeWizard('sfBannersPluginToContentElementUpdate')]
class PluginToContentElementUpdater extends AbstractListTypeToCTypeUpdate
{
protected function getListTypeToCTypeMapping(): array
{
return [
'sfbanners_pi1' => 'sfbanners_pi1',
];
}

public function getTitle(): string
{
return 'ext:sf_banners: Migrate plugins to content elements';
}

public function getDescription(): string
{
return 'Migrates existing plugin records and backend user permissions used by ext:banners';
}
}
9 changes: 9 additions & 0 deletions Configuration/Extbase/Persistence/Classes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

return [
\DERHANSEN\SfBanners\Domain\Model\Page::class => [
'tableName' => 'pages',
],
];
138 changes: 64 additions & 74 deletions Configuration/Flexforms/Flexform_plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,86 +6,76 @@
<type>array</type>
<el>
<settings.displayMode>
<TCEforms>
<label>LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.displayMode</label>
<onChange>reload</onChange>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items>
<numIndex index="0" type="array">
<numIndex index="0">LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.displayMode.all</numIndex>
<numIndex index="1">all</numIndex>
</numIndex>
<numIndex index="1">
<numIndex index="0">LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.displayMode.allRandom</numIndex>
<numIndex index="1">allRandom</numIndex>
</numIndex>
<numIndex index="2">
<numIndex index="0">LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.displayMode.random</numIndex>
<numIndex index="1">random</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
<label>LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.displayMode</label>
<onChange>reload</onChange>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items>
<numIndex index="0" type="array">
<label>LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.displayMode.all</label>
<value>all</value>
</numIndex>
<numIndex index="1">
<label>LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.displayMode.allRandom</label>
<value>allRandom</value>
</numIndex>
<numIndex index="2">
<label>LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.displayMode.random</label>
<value>random</value>
</numIndex>
</items>
</config>
</settings.displayMode>
<settings.maxResults>
<TCEforms>
<label>LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.maxResults</label>
<displayCond>
<OR>
<numIndex index="0">FIELD:settings.displayMode:=:all</numIndex>
<numIndex index="1">FIELD:settings.displayMode:=:allRandom</numIndex>
</OR>
</displayCond>
<config>
<type>input</type>
<eval>num</eval>
<size>5</size>
</config>
</TCEforms>
<label>LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.maxResults</label>
<displayCond>
<OR>
<numIndex index="0">FIELD:settings.displayMode:=:all</numIndex>
<numIndex index="1">FIELD:settings.displayMode:=:allRandom</numIndex>
</OR>
</displayCond>
<config>
<type>number</type>
<size>5</size>
</config>
</settings.maxResults>
<settings.startingPoint>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.startingPoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>3</size>
<maxitems>50</maxitems>
<minitems>0</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.startingPoint</label>
<config>
<type>group</type>
<allowed>pages</allowed>
<size>3</size>
<maxitems>50</maxitems>
<minitems>0</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</settings.startingPoint>
<settings.category>
<TCEforms>
<label>LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.category</label>
<config>
<type>select</type>
<renderType>selectTree</renderType>
<treeConfig>
<parentField>parent</parentField>
<appearance>
<expandAll>TRUE</expandAll>
<showHeader>TRUE</showHeader>
</appearance>
</treeConfig>
<foreign_table>sys_category</foreign_table>
<foreign_table_where> AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.title ASC</foreign_table_where>
<size>10</size>
<autoSizeMax>10</autoSizeMax>
<minitems>0</minitems>
<maxitems>999</maxitems>
</config>
</TCEforms>
<label>LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xlf:plugin.settings.category</label>
<config>
<type>select</type>
<renderType>selectTree</renderType>
<treeConfig>
<parentField>parent</parentField>
<appearance>
<expandAll>TRUE</expandAll>
<showHeader>TRUE</showHeader>
</appearance>
</treeConfig>
<foreign_table>sys_category</foreign_table>
<foreign_table_where> AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.title ASC</foreign_table_where>
<size>10</size>
<autoSizeMax>10</autoSizeMax>
<minitems>0</minitems>
<maxitems>999</maxitems>
</config>
</settings.category>

</el>
Expand Down
29 changes: 23 additions & 6 deletions Configuration/TCA/Overrides/tt_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,31 @@
*/
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['sfbanners_pi1'] = 'pi_flexform';
ExtensionManagementUtility::addPiFlexFormValue(
'sfbanners_pi1',
'FILE:EXT:sf_banners/Configuration/Flexforms/Flexform_plugin.xml'
'*',
'FILE:EXT:sf_banners/Configuration/Flexforms/Flexform_plugin.xml',
'sfbanners_pi1'
);

/**
* Remove unused fields
*/
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['sfbanners_pi1'] = 'layout,recursive,select_key,pages';
$GLOBALS['TCA']['tt_content']['types']['sfbanners_pi1']['showitem'] = '
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
--palette--;;general,
--palette--;;headers,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.plugin,
pi_flexform,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,
--palette--;;frames,
--palette--;;appearanceLinks,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
--palette--;;language,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
--palette--;;hidden,
--palette--;;access,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
categories,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,
rowDescription,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
';

/**
* Default TypoScript
Expand Down
Loading

0 comments on commit a001e1f

Please sign in to comment.