Skip to content

Commit 41d143f

Browse files
committed
[TASK] cleanup code for TYPO3 > 12
1 parent f417a70 commit 41d143f

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

Build/phpstan-baseline-13.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,7 @@ parameters:
7272
message: "#^Parameter \\#4 \\$drawingConfiguration of class TYPO3\\\\CMS\\\\Backend\\\\View\\\\PageLayoutContext constructor expects TYPO3\\\\CMS\\\\Backend\\\\View\\\\Drawing\\\\DrawingConfiguration, PHPUnit\\\\Framework\\\\MockObject\\\\MockObject&TYPO3\\\\CMS\\\\Core\\\\Http\\\\ServerRequest given\\.$#"
7373
count: 1
7474
path: ../Tests/Functional/Integrity/IntegrityTest.php
75+
-
76+
message: "#^Access to an undefined property B13\\\\Container\\\\Backend\\\\ContextMenu\\\\RecordContextMenuItemProvider\\:\\:\\$uriBuilder\\.$#"
77+
count: 1
78+
path: ../Classes/Backend/ContextMenu/RecordContextMenuItemProvider.php

Classes/Backend/ContextMenu/RecordContextMenuItemProvider.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@
55
namespace B13\Container\Backend\ContextMenu;
66

77
use TYPO3\CMS\Backend\Routing\UriBuilder;
8+
use TYPO3\CMS\Core\Information\Typo3Version;
9+
use TYPO3\CMS\Core\Utility\GeneralUtility;
810

911
class RecordContextMenuItemProvider extends \TYPO3\CMS\Backend\ContextMenu\ItemProviders\RecordProvider
1012
{
11-
public function __construct(protected UriBuilder $uriBuilder)
12-
{
13-
parent::__construct();
14-
}
15-
1613
/**
1714
* Add tx_container_parent to newContentElementWizard Url if it is a tt_content record in a container
1815
*/
@@ -29,7 +26,12 @@ protected function getAdditionalAttributes(string $itemName): array
2926
'uid_pid' => -$this->record['uid'],
3027
'tx_container_parent' => $this->record['tx_container_parent'],
3128
];
32-
$url = (string)$this->uriBuilder->buildUriFromRoute('new_content_element_wizard', $urlParameters);
29+
if ((new Typo3Version())->getMajorVersion() < 14) {
30+
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
31+
$url = (string)$uriBuilder->buildUriFromRoute('new_content_element_wizard', $urlParameters);
32+
} else {
33+
$url = (string)$this->uriBuilder->buildUriFromRoute('new_content_element_wizard', $urlParameters);
34+
}
3335
if (isset($attributes['data-new-wizard-url'])) {
3436
$attributes['data-new-wizard-url'] = $url;
3537
}

Tests/Unit/Tca/RegistryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class RegistryTest extends UnitTestCase
2727
public function getAllAvailableColumnsReturnsEmptyArrayIfNoContainerConfigured(): void
2828
{
2929
$eventDispatcher = new NoopEventDispatcher();
30-
$iconRegistry = $this->getMockBuilder(IconRegistry::class)->disableOriginalConstructor()->getMock();
30+
$iconRegistry = $this->createMock(IconRegistry::class);
3131
$registry = GeneralUtility::makeInstance(Registry::class, $eventDispatcher, $iconRegistry);
3232
$columns = $registry->getAllAvailableColumns();
3333
self::assertSame([], $columns);
@@ -37,7 +37,7 @@ public function getAllAvailableColumnsReturnsEmptyArrayIfNoContainerConfigured()
3737
public function getPageTsStringReturnsEmptyStringIfNoContainerConfigured(): void
3838
{
3939
$eventDispatcher = new NoopEventDispatcher();
40-
$iconRegistry = $this->getMockBuilder(IconRegistry::class)->disableOriginalConstructor()->getMock();
40+
$iconRegistry = $this->createMock(IconRegistry::class);
4141
$registry = GeneralUtility::makeInstance(Registry::class, $eventDispatcher, $iconRegistry);
4242
$res = $registry->getPageTsString();
4343
self::assertSame('', $res, 'empty string should be returned');

0 commit comments

Comments
 (0)