Skip to content

Commit afbd7de

Browse files
committed
[TASK] cleanup code for TYPO3 > 12
1 parent 78aebfb commit afbd7de

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

Classes/Backend/ContextMenu/RecordContextMenuItemProvider.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,28 @@
99

1010
class RecordContextMenuItemProvider extends \TYPO3\CMS\Backend\ContextMenu\ItemProviders\RecordProvider
1111
{
12+
public function __construct(protected UriBuilder $uriBuilder)
13+
{
14+
parent::__construct();
15+
}
16+
1217
/**
1318
* Add tx_container_parent to newContentElementWizard Url if it is a tt_content record in a container
14-
*
15-
* @param string $itemName
16-
*
17-
* @return array
18-
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
1919
*/
2020
protected function getAdditionalAttributes(string $itemName): array
2121
{
2222
$attributes = parent::getAdditionalAttributes($itemName);
2323
if ($itemName === 'newWizard' && $this->table === 'tt_content'
2424
&& isset($this->record['tx_container_parent']) && $this->record['tx_container_parent'] > 0) {
25-
$languageField = method_exists($this, 'getLanguageField') ? $this->getLanguageField() : $GLOBALS['TCA']['tt_content']['ctrl']['languageField'];
25+
$languageField = $this->getLanguageField();
2626
$urlParameters = [
2727
'id' => $this->record['pid'],
2828
'sys_language_uid' => $this->record[$languageField] ?? null,
2929
'colPos' => $this->record['colPos'],
3030
'uid_pid' => -$this->record['uid'],
3131
'tx_container_parent' => $this->record['tx_container_parent'],
3232
];
33-
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
34-
$url = (string)$uriBuilder->buildUriFromRoute('new_content_element_wizard', $urlParameters);
33+
$url = (string)$this->uriBuilder->buildUriFromRoute('new_content_element_wizard', $urlParameters);
3534
if (isset($attributes['data-new-wizard-url'])) {
3635
$attributes['data-new-wizard-url'] = $url;
3736
}

Tests/Unit/Tca/RegistryTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,33 @@
1313
*/
1414

1515
use B13\Container\Tca\Registry;
16+
use PHPUnit\Framework\Attributes\Test;
1617
use TYPO3\CMS\Core\EventDispatcher\NoopEventDispatcher;
18+
use TYPO3\CMS\Core\Imaging\IconRegistry;
1719
use TYPO3\CMS\Core\Utility\GeneralUtility;
1820
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
1921

2022
class RegistryTest extends UnitTestCase
2123
{
2224
protected bool $resetSingletonInstances = true;
2325

24-
/**
25-
* @test
26-
*/
26+
27+
#[Test]
2728
public function getAllAvailableColumnsReturnsEmptyArrayIfNoContainerConfigured(): void
2829
{
2930
$eventDispatcher = new NoopEventDispatcher();
30-
$registry = GeneralUtility::makeInstance(Registry::class, $eventDispatcher);
31+
$iconRegistry = $this->getMockBuilder(IconRegistry::class)->disableOriginalConstructor()->getMock();
32+
$registry = GeneralUtility::makeInstance(Registry::class, $eventDispatcher, $iconRegistry);
3133
$columns = $registry->getAllAvailableColumns();
3234
self::assertSame([], $columns);
3335
}
3436

35-
/**
36-
* @test
37-
*/
37+
#[Test]
3838
public function getPageTsStringReturnsEmptyStringIfNoContainerConfigured(): void
3939
{
4040
$eventDispatcher = new NoopEventDispatcher();
41-
$registry = GeneralUtility::makeInstance(Registry::class, $eventDispatcher);
41+
$iconRegistry = $this->getMockBuilder(IconRegistry::class)->disableOriginalConstructor()->getMock();
42+
$registry = GeneralUtility::makeInstance(Registry::class, $eventDispatcher, $iconRegistry);
4243
$res = $registry->getPageTsString();
4344
self::assertSame('', $res, 'empty string should be returned');
4445
}

0 commit comments

Comments
 (0)