Skip to content

Commit 6f71f59

Browse files
author
Mathis Koblin
committed
Upgraded code to TYPO3 v13
1 parent 7a646fa commit 6f71f59

33 files changed

+300
-315
lines changed

.github/workflows/analyze.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
name: '✔ with SonarCloud'
1717

1818
env:
19-
php: '8.2'
20-
typo3: '^12.4'
19+
php: '8.3'
20+
typo3: '^13.4'
2121
sonar_token: ${{ secrets.SONAR_TOKEN }}
2222

2323
if: github.repository == 'IchHabRecht/social_gdpr'

.github/workflows/dev.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
os: [ 'ubuntu-latest' ]
18-
typo3: [ '10.4.x-dev', '11.5.x-dev', '12.4.x-dev' ]
19-
php: [ '7.4', '8.0', '8.1' ]
18+
typo3: [ '13.4.x-dev' ]
19+
php: [ '8.2', '8.3', '8.4' ]
2020
dependency-version: [ 'lowest', 'stable' ]
2121
exclude:
2222
- typo3: '10.4.x-dev'
@@ -96,7 +96,7 @@ jobs:
9696
typo3DatabasePassword: 'root'
9797
typo3DatabaseUsername: 'root'
9898
run: |
99-
sudo /etc/init.d/mysql start
99+
sudo /etc/init.d/mysql start
100100
mkdir -p .Build/public/typo3conf/ext/
101101
if [ ! -L .Build/public/typo3conf/ext/social_gdpr ]; then ln -snvf ../../../../. .Build/public/typo3conf/ext/social_gdpr; fi
102102
find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo "Running functional test suite {}"; .Build/bin/phpunit --bootstrap .Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php {}'

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
name: '🚢 to TER'
1414

1515
env:
16-
php: '8.2'
17-
typo3: '^12.4'
16+
php: '8.3'
17+
typo3: '^13.4'
1818
typo3_org_username: ${{ secrets.TYPO3_ORG_USERNAME }}
1919
typo3_org_password: ${{ secrets.TYPO3_ORG_PASSWORD }}
2020

.github/workflows/test.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,8 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
os: [ 'ubuntu-latest' ]
16-
typo3: [ '^10.4', '^11.5', '^12.4' ]
17-
php: [ '7.4', '8.0', '8.1' ]
18-
exclude:
19-
- typo3: '^10.4'
20-
php: '8.0'
21-
- typo3: '^10.4'
22-
php: '8.1'
23-
- typo3: '^12.4'
24-
php: '7.4'
25-
- typo3: '^12.4'
26-
php: '8.0'
16+
typo3: [ '^13.4' ]
17+
php: [ '8.2', '8.3', '8.4' ]
2718

2819
runs-on: ${{ matrix.os }}
2920

@@ -90,7 +81,7 @@ jobs:
9081
typo3DatabasePassword: 'root'
9182
typo3DatabaseUsername: 'root'
9283
run: |
93-
sudo /etc/init.d/mysql start
84+
sudo /etc/init.d/mysql start
9485
mkdir -p .Build/public/typo3conf/ext/
9586
if [ ! -L .Build/public/typo3conf/ext/social_gdpr ]; then ln -snvf ../../../../. .Build/public/typo3conf/ext/social_gdpr; fi
9687
find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo "Running functional test suite {}"; HASH=${{ steps.version-cache.outputs.version }}_$( echo {} | md5sum | cut -d " " -f 1); .Build/bin/phpunit --bootstrap .Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php --log-junit .Log/junit/functional_$HASH.xml --coverage-php .Log/coverage/functional_$HASH.cov {}'

Classes/Controller/PreviewImageFlushController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Psr\Http\Message\ResponseInterface;
99
use Psr\Http\Message\ServerRequestInterface;
1010
use TYPO3\CMS\Core\Http\JsonResponse;
11-
use TYPO3\CMS\Core\Messaging\AbstractMessage;
11+
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
1212
use TYPO3\CMS\Core\Utility\GeneralUtility;
1313

1414
class PreviewImageFlushController
@@ -18,20 +18,20 @@ public function flush(ServerRequestInterface $serverRequest): ResponseInterface
1818
$youtubeId = $serverRequest->getParsedBody()['id'] ?? null;
1919
$type = $serverRequest->getParsedBody()['type'] ?? null;
2020
if ($youtubeId === null) {
21-
return new JsonResponse(['status' => AbstractMessage::ERROR, 'message' => 'Missing id']);
21+
return new JsonResponse(['status' => ContextualFeedbackSeverity::ERROR, 'message' => 'Missing id']);
2222
}
2323
if ($type === null) {
24-
return new JsonResponse(['status' => AbstractMessage::ERROR, 'message' => 'Missing type']);
24+
return new JsonResponse(['status' => ContextualFeedbackSeverity::ERROR, 'message' => 'Missing type']);
2525
}
2626

2727
$previewImageServiceRegistry = GeneralUtility::makeInstance(PreviewImageServiceRegistry::class);
2828
$previewImageService = $previewImageServiceRegistry->getPreviewImageService($type);
2929

3030
if (!$previewImageService->hasPreviewImage($youtubeId)) {
31-
return new JsonResponse(['status' => AbstractMessage::INFO, 'message' => 'Preview image does not exist']);
31+
return new JsonResponse(['status' => ContextualFeedbackSeverity::INFO, 'message' => 'Preview image does not exist']);
3232
}
3333
$previewImageService->deletePreviewImage($youtubeId);
3434

35-
return new JsonResponse(['status' => AbstractMessage::OK, 'message' => 'Preview image deleted']);
35+
return new JsonResponse(['status' => ContextualFeedbackSeverity::OK, 'message' => 'Preview image deleted']);
3636
}
3737
}

Classes/Hooks/ContentPostProcessHook.php renamed to Classes/EventListener/ContentPostProcessEventListener.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,38 @@
22

33
declare(strict_types=1);
44

5-
namespace IchHabRecht\SocialGdpr\Hooks;
5+
namespace IchHabRecht\SocialGdpr\EventListener;
66

77
use IchHabRecht\SocialGdpr\Handler\ContentMatch;
88
use IchHabRecht\SocialGdpr\Handler\HandlerInterface;
9+
use Psr\Http\Message\ServerRequestInterface;
10+
use TYPO3\CMS\Core\Attribute\AsEventListener;
911
use TYPO3\CMS\Core\Utility\GeneralUtility;
1012
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
1113
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
14+
use TYPO3\CMS\Frontend\Event\AfterCacheableContentIsGeneratedEvent;
1215

13-
class ContentPostProcessHook
16+
#[AsEventListener(
17+
identifier: 'socialgdprAfterCacheableContentIsGeneratedEventListener',
18+
)]
19+
final readonly class ContentPostProcessEventListener
1420
{
1521
/**
1622
* @var ContentObjectRenderer|null
1723
*/
18-
protected $contentObjectRenderer;
24+
protected object $contentObjectRenderer;
1925

2026
public function __construct(ContentObjectRenderer $contentObjectRenderer = null)
2127
{
2228
$this->contentObjectRenderer = $contentObjectRenderer ?: GeneralUtility::makeInstance(ContentObjectRenderer::class);
2329
}
2430

25-
public function replaceSocialMediaWithEvent(\TYPO3\CMS\Frontend\Event\AfterCacheableContentIsGeneratedEvent $event)
31+
public function __invoke(AfterCacheableContentIsGeneratedEvent $event): void
2632
{
27-
$this->replaceSocialMediaInContent($event->getController());
33+
$this->replaceSocialMediaInContent($event->getController(), $event->getRequest());
2834
}
2935

30-
public function replaceSocialMedia(array $parameter)
31-
{
32-
$this->replaceSocialMediaInContent($parameter['pObj']);
33-
}
34-
35-
protected function replaceSocialMediaInContent(TypoScriptFrontendController $typoScriptFrontendController)
36+
protected function replaceSocialMediaInContent(TypoScriptFrontendController $typoScriptFrontendController, ServerRequestInterface $request): void
3637
{
3738
$content = $typoScriptFrontendController->content;
3839

@@ -63,7 +64,8 @@ protected function replaceSocialMediaInContent(TypoScriptFrontendController $typ
6364
);
6465

6566
$this->contentObjectRenderer->start($data, 'tt_content');
66-
$handlerContent = $this->contentObjectRenderer->cObjGetSingle($typoScriptFrontendController->tmpl->setup['lib.']['socialgdpr'], $typoScriptFrontendController->tmpl->setup['lib.']['socialgdpr.']);
67+
$typoScript = $request->getAttribute('frontend.typoscript')->getSetupArray();
68+
$handlerContent = $this->contentObjectRenderer->cObjGetSingle($typoScript['lib.']['socialgdpr'], $typoScript['lib.']['socialgdpr.']);
6769
$content = str_replace($match->getSearch(), $handlerContent, $content);
6870
}
6971
}

Classes/ExtensionConfiguration.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@
99

1010
class ExtensionConfiguration implements SingletonInterface
1111
{
12-
/**
13-
* @var array
14-
*/
15-
protected $settings = [];
12+
protected ?array $settings;
1613

17-
public function __construct(array $settings = null)
14+
public function __construct(?array $settings = null)
1815
{
1916
if ($settings === null) {
20-
if (class_exists('TYPO3\\CMS\\Core\\Configuration\\ExtensionConfiguration')) {
17+
if (class_exists(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)) {
2118
$settings = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get('social_gdpr');
2219
} else {
2320
$settings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['social_gdpr'], ['allowed_classes' => false]);
@@ -26,7 +23,7 @@ public function __construct(array $settings = null)
2623
$this->settings = $settings;
2724
}
2825

29-
public function isEnabled($key)
26+
public function isEnabled($key): bool
3027
{
3128
return !empty($this->settings[$key]);
3229
}

Classes/Form/CustomInlineControl/OnlineFalMediaPreviewFlush.php renamed to Classes/Form/CustomInlineControl/OnlineFalMediaPreviewFlushEventListener.php

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
namespace IchHabRecht\SocialGdpr\Form\CustomInlineControl;
66

77
use IchHabRecht\SocialGdpr\Service\PreviewImageServiceRegistry;
8-
use TYPO3\CMS\Backend\Form\Element\InlineElementHookInterface;
98
use TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceControlsEvent;
9+
use TYPO3\CMS\Backend\Form\Event\ModifyInlineElementControlsEvent;
10+
use TYPO3\CMS\Backend\Form\Event\ModifyInlineElementEnabledControlsEvent;
11+
use TYPO3\CMS\Core\Attribute\AsEventListener;
1012
use TYPO3\CMS\Core\Imaging\Icon;
1113
use TYPO3\CMS\Core\Imaging\IconFactory;
1214
use TYPO3\CMS\Core\Imaging\IconRegistry;
@@ -15,7 +17,18 @@
1517
use TYPO3\CMS\Core\Resource\ResourceFactory;
1618
use TYPO3\CMS\Core\Utility\GeneralUtility;
1719

18-
class OnlineFalMediaPreviewFlush implements InlineElementHookInterface
20+
21+
#[AsEventListener(
22+
identifier: 'socialgdprModifyFileReferenceControlsEvent',
23+
event: ModifyFileReferenceControlsEvent::class,
24+
method: 'renderFileReferenceHeaderControl',
25+
)]
26+
#[AsEventListener(
27+
identifier: 'socialgdprModifyInlineElementControlsEvent',
28+
event: ModifyInlineElementControlsEvent::class,
29+
method: 'modifyControls',
30+
)]
31+
class OnlineFalMediaPreviewFlushEventListener
1932
{
2033
protected IconFactory $iconFactory;
2134

@@ -30,12 +43,12 @@ class OnlineFalMediaPreviewFlush implements InlineElementHookInterface
3043
protected ResourceFactory $resourceFactory;
3144

3245
public function __construct(
33-
IconFactory $iconFactory = null,
34-
IconRegistry $iconRegistry = null,
35-
OnlineMediaHelperRegistry $onlineMediaRegistry = null,
36-
PageRenderer $pageRenderer = null,
37-
PreviewImageServiceRegistry $previewImageServiceRegistry = null,
38-
ResourceFactory $resourceFactory = null
46+
?IconFactory $iconFactory = null,
47+
?IconRegistry $iconRegistry = null,
48+
?OnlineMediaHelperRegistry $onlineMediaRegistry = null,
49+
?PageRenderer $pageRenderer = null,
50+
?PreviewImageServiceRegistry $previewImageServiceRegistry = null,
51+
?ResourceFactory $resourceFactory = null
3952
) {
4053
$this->iconFactory = $iconFactory ?: GeneralUtility::makeInstance(IconFactory::class);
4154
$this->iconRegistry = $iconRegistry ?: GeneralUtility::makeInstance(IconRegistry::class);
@@ -45,7 +58,7 @@ public function __construct(
4558
$this->resourceFactory = $resourceFactory ?: GeneralUtility::makeInstance(ResourceFactory::class);
4659
}
4760

48-
public function renderFileReferenceHeaderControl(ModifyFileReferenceControlsEvent $event)
61+
public function renderFileReferenceHeaderControl(ModifyFileReferenceControlsEvent $event): void
4962
{
5063
$elementData = $event->getElementData();
5164
if ($elementData['tableName'] !== 'sys_file_reference') {
@@ -61,32 +74,15 @@ public function renderFileReferenceHeaderControl(ModifyFileReferenceControlsEven
6174
return;
6275
}
6376

64-
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/SocialGdpr/Backend/PreviewImageFlush');
77+
$this->pageRenderer->loadJavaScriptModule('@vendor/social_gdpr/Backend/PreviewImageFlush.js');
6578
$controls = $event->getControls();
6679
$controls['youtubeFlush'] = $this->renderControlItem($record);
6780
$event->setControls($controls);
6881
}
6982

70-
public function renderForeignRecordHeaderControl_preProcess(
71-
$parentUid,
72-
$foreignTable,
73-
array $childRecord,
74-
array $childConfig,
75-
$isVirtual,
76-
array &$enabledControls
77-
) {
78-
// Do nothing.
79-
}
80-
81-
public function renderForeignRecordHeaderControl_postProcess(
82-
$parentUid,
83-
$foreignTable,
84-
array $childRecord,
85-
array $childConfig,
86-
$isVirtual,
87-
array &$controlItems
88-
) {
89-
if ($foreignTable !== 'sys_file_reference') {
83+
public function modifyControls(ModifyInlineElementControlsEvent $event): void
84+
{
85+
if ($event->getElementData()['inlineParentTableName'] !== 'sys_file_reference') {
9086
return;
9187
}
9288

@@ -98,8 +94,9 @@ public function renderForeignRecordHeaderControl_postProcess(
9894
return;
9995
}
10096

101-
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/SocialGdpr/Backend/PreviewImageFlush');
97+
$this->pageRenderer->loadJavaScriptModule('@vendor/social_gdpr/Backend/PreviewImageFlush.js');
10298
$controlItems['youtubeFlush'] = $this->renderControlItem($childRecord);
99+
$event->setControls($controlItems);
103100
}
104101

105102
protected function renderControlItem(array $record): string

Classes/Handler/ContentMatch.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,8 @@
66

77
class ContentMatch
88
{
9-
/**
10-
* @var array
11-
*/
12-
protected $data = [];
13-
14-
/**
15-
* @var string
16-
*/
17-
protected $search;
18-
19-
public function __construct(string $search, array $data = [])
9+
public function __construct(protected string $search, protected array $data = [])
2010
{
21-
$this->search = $search;
22-
$this->data = $data;
2311
}
2412

2513
public function getData(): array

Classes/Handler/GoogleMapsIframeHandler.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ class GoogleMapsIframeHandler implements HandlerInterface
1414
*/
1515
protected $matches = [];
1616

17-
/**
18-
* @param string $content
19-
* @return bool
20-
*/
2117
public function hasMatches(string $content): bool
2218
{
2319
preg_match_all(
@@ -36,17 +32,15 @@ public function hasMatches(string $content): bool
3632
public function getMatches(): array
3733
{
3834
return array_map(
39-
function ($match) {
40-
return new ContentMatch(
41-
$match[0],
42-
[
43-
'uid' => StringUtility::getUniqueId(),
44-
'iframeHash' => base64_encode($match[0]),
45-
'height' => !empty($match['height']) ? (MathUtility::canBeInterpretedAsInteger($match['height']) ? $match['height'] . 'px' : $match['height']) : 0,
46-
'width' => !empty($match['width']) ? (MathUtility::canBeInterpretedAsInteger($match['width']) ? $match['width'] . 'px' : $match['width']) : 0,
47-
]
48-
);
49-
},
35+
fn($match): \IchHabRecht\SocialGdpr\Handler\ContentMatch => new ContentMatch(
36+
$match[0],
37+
[
38+
'uid' => StringUtility::getUniqueId(),
39+
'iframeHash' => base64_encode($match[0]),
40+
'height' => !empty($match['height']) ? (MathUtility::canBeInterpretedAsInteger($match['height']) ? $match['height'] . 'px' : $match['height']) : 0,
41+
'width' => !empty($match['width']) ? (MathUtility::canBeInterpretedAsInteger($match['width']) ? $match['width'] . 'px' : $match['width']) : 0,
42+
]
43+
),
5044
$this->matches
5145
);
5246
}

0 commit comments

Comments
 (0)