Skip to content

Commit

Permalink
chore: update for TYPO3 v12 - remove deprecations, fix some issues, a…
Browse files Browse the repository at this point in the history
…djust tests, convert fixtures
  • Loading branch information
tlayh committed Jun 27, 2024
1 parent ef645be commit a585493
Show file tree
Hide file tree
Showing 24 changed files with 88 additions and 176 deletions.
17 changes: 16 additions & 1 deletion .code-quality/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\View\\\\ViewInterface\\:\\:setTemplate\\(\\)\\.$#"
message: "#^Parameter \\#2 \\$conf of method TYPO3\\\\CMS\\\\Frontend\\\\ContentObject\\\\ContentObjectRenderer\\:\\:parseFunc\\(\\) expects non\\-empty\\-array\\<string, mixed\\>\\|null, array given\\.$#"
count: 1
path: ../Classes/Service/RenderingService.php

-
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\View\\\\ViewInterface\\:\\:setTemplate\\(\\)\\.$#"
count: 1
path: ../Classes/Typo3/Hook/LinkWizzard.php

-
message: "#^Call to method displayRecordsForPage\\(\\) on an unknown class TYPO3\\\\CMS\\\\Recordlist\\\\Browser\\\\RecordBrowser\\.$#"
count: 1
path: ../Classes/Typo3/Hook/LinkWizzard.php

-
message: "#^Class TYPO3\\\\CMS\\\\Recordlist\\\\Browser\\\\RecordBrowser not found\\.$#"
count: 1
path: ../Classes/Typo3/Hook/LinkWizzard.php
2 changes: 0 additions & 2 deletions .code-quality/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Rector\Set\ValueObject\SetList;
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector;

Expand All @@ -34,7 +33,6 @@
PHPUnitSetList::PHPUNIT_CODE_QUALITY
])
->withSkip([
FinalizeClassesWithoutChildrenRector::class,
ChangeAndIfToEarlyReturnRector::class,
TypedPropertyFromStrictSetUpRector::class,
AddMethodCallBasedStrictParamTypeRector::class,
Expand Down
3 changes: 2 additions & 1 deletion Classes/Domain/Repository/FootnoteRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function getLowestFreeIndexNumber(): int
$queryBuilder->expr()
->eq('deleted', $queryBuilder->createNamedParameter(0, PDO::PARAM_INT))
)
->execute()
->executeQuery()
->fetchAllAssociative();

$index = 1;
Expand Down Expand Up @@ -120,6 +120,7 @@ public function getFootnoteByUid($uid)
$query = $this->createQuery();
$query->setQuerySettings($this->defaultQuerySettings);

/** @var Footnote */
return $query->matching($query->equals('uid', $uid))
->execute()
->getFirst();
Expand Down
8 changes: 3 additions & 5 deletions Classes/Service/FCEFootnoteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ class FCEFootnoteService
{
public ?ContentObjectRenderer $cObj = null;

private RenderingService $renderingService;

public function __construct(RenderingService $renderingService)
{
$this->renderingService = $renderingService;
public function __construct(
private RenderingService $renderingService
) {
}

/**
Expand Down
8 changes: 3 additions & 5 deletions Classes/Service/FootnoteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@

class FootnoteService
{
private FootnoteRepository $footnoteRepository;

public function __construct(FootnoteRepository $footnoteRepository)
{
$this->footnoteRepository = $footnoteRepository;
public function __construct(
private FootnoteRepository $footnoteRepository
) {
}

/**
Expand Down
10 changes: 4 additions & 6 deletions Classes/Service/RenderingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ class RenderingService implements SingletonInterface

private ?ContentObjectRenderer $contentObjectRenderer = null;

private FootnoteRepository $footnoteRepository;

public function __construct(FootnoteRepository $footnoteRepository)
{
$this->footnoteRepository = $footnoteRepository;
public function __construct(
private FootnoteRepository $footnoteRepository
) {
}

/**
Expand Down Expand Up @@ -87,7 +85,7 @@ public function renderFootnotes(array $uids, array $conf = []): ?string
* of the object path "lib.parseFunc" will be retrieved and MERGED with what is in $conf!
* @return string
*/
public function renderRichText($richText, array $conf = [], $ref = '< lib.parseFunc_HappyFeet')
public function renderRichText($richText, array $conf = [], ?string $ref = '< lib.parseFunc_HappyFeet')
{
if ($richText === '') {
return '';
Expand Down
11 changes: 5 additions & 6 deletions Classes/Typo3/Hook/LinkWizzard.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
*/

use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Controller\AbstractLinkBrowserController;
use TYPO3\CMS\Backend\LinkHandler\AbstractLinkHandler;
use TYPO3\CMS\Backend\LinkHandler\LinkHandlerInterface;
use TYPO3\CMS\Backend\Tree\View\LinkParameterProviderInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\LinkHandling\LinkService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Recordlist\Browser\RecordBrowser;
use TYPO3\CMS\Recordlist\Controller\AbstractLinkBrowserController;
use TYPO3\CMS\Recordlist\LinkHandler\AbstractLinkHandler;
use TYPO3\CMS\Recordlist\LinkHandler\LinkHandlerInterface;
use TYPO3\CMS\Recordlist\Tree\View\LinkParameterProviderInterface;

/**
* Link handler for arbitrary database records
Expand All @@ -48,10 +48,9 @@ final class LinkWizzard extends AbstractLinkHandler implements LinkHandlerInterf
/**
* Initializes the handler.
*
* @param mixed $identifier
* @param array $configuration Page TSconfig
*/
public function initialize(AbstractLinkBrowserController $linkBrowser, $identifier, array $configuration): void
public function initialize(AbstractLinkBrowserController $linkBrowser, mixed $identifier, array $configuration): void
{
parent::initialize($linkBrowser, $identifier, $configuration);
$this->configuration = $configuration;
Expand Down
8 changes: 3 additions & 5 deletions Classes/Typo3/Hook/Tcemain.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@
*/
class Tcemain
{
private FootnoteRepository $footnoteRepository;

public function __construct(FootnoteRepository $footnoteRepository)
{
$this->footnoteRepository = $footnoteRepository;
public function __construct(
private FootnoteRepository $footnoteRepository
) {
}

/**
Expand Down
4 changes: 0 additions & 4 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ services:
resource: '../Classes/*'

AOE\HappyFeet\Typo3\Hook\LinkRenderer:
public: true

AOE\HappyFeet\Typo3\Hook\Tcemain:
public: true

AOE\HappyFeet\Service\RenderingService:
public: true

AOE\HappyFeet\Domain\Repository\FootnoteRepository:
public: true
24 changes: 17 additions & 7 deletions Configuration/TCA/tx_happyfeet_domain_model_footnote.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@
'foreign_table' => 'sys_language',
'foreign_table_where' => 'ORDER BY sys_language.title',
'items' => [
['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', -1],
['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.default_value', 0]
[
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages',
'value' => -1,
],
[
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.default_value',
'value' => 0,
],
]
]
],
Expand All @@ -37,7 +43,10 @@
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['', 0],
[
'label' => '',
'value' => 0,
],
],
'foreign_table' => 'tx_happyfeet_domain_model_footnote',
'foreign_table_where' => 'AND tx_happyfeet_domain_model_footnote.pid=###CURRENT_PID### AND tx_happyfeet_domain_model_footnote.sys_language_uid IN (-1,0)',
Expand All @@ -62,7 +71,7 @@
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.starttime',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'renderType' => 'datetime',
'size' => '8',
'eval' => 'date',
'default' => '0',
Expand All @@ -74,7 +83,7 @@
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.endtime',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'renderType' => 'datetime',
'size' => '8',
'eval' => 'date',
'checkbox' => '0',
Expand All @@ -93,10 +102,11 @@
'title' => [
'exclude' => 0,
'label' => 'LLL:EXT:happy_feet/Resources/Private/Language/locallang_db.xlf:tx_happyfeet_domain_model_footnote.title',
'required' => true,
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim,required,unique'
'eval' => 'trim,unique'
]
],
'header' => [
Expand All @@ -111,11 +121,11 @@
'description' => [
'exclude' => 0,
'label' => 'LLL:EXT:happy_feet/Resources/Private/Language/locallang_db.xlf:tx_happyfeet_domain_model_footnote.description',
'required' => true,
'config' => [
'type' => 'text',
'cols' => '30',
'rows' => '5',
'eval' => 'required',
'enableRichtext' => true
],
]
Expand Down
16 changes: 8 additions & 8 deletions Tests/Functional/Domain/Repository/FootnoteRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,43 +63,43 @@ public function testShouldGetDefaultIndexWhenNoRecordsAvailable(): void

public function testShouldGetLowestIndex(): void
{
$this->importDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote.xml');
$this->importCSVDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote.csv');
$lowestIndex = $this->repository->getLowestFreeIndexNumber();
$this->assertSame(1, $lowestIndex);
}

public function testShouldGetIndexWithGap(): void
{
$this->importDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote_gap.xml');
$this->importCSVDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote_gap.csv');
$lowestIndex = $this->repository->getLowestFreeIndexNumber();
$this->assertSame(2, $lowestIndex);
}

public function testShouldGetNextIndexInRow(): void
{
$this->importDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote_row.xml');
$this->importCSVDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote_row.csv');
$lowestIndex = $this->repository->getLowestFreeIndexNumber();
$this->assertSame(3, $lowestIndex);
}

public function testShouldGetFootnoteByUid(): void
{
$this->importDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote.xml');
$this->importCSVDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote.csv');
$footnote = $this->repository->getFootnoteByUid(1);
$this->assertInstanceOf(Footnote::class, $footnote);
$this->assertSame(1, $footnote->getUid());
}

public function testShouldReturnNullIfFootnoteNotFound(): void
{
$this->importDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote.xml');
$this->importCSVDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote.csv');
$footnote = $this->repository->getFootnoteByUid(99);
$this->assertNull($footnote);
}

public function testShouldGetFootnotesByUids(): void
{
$this->importDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote_collection.xml');
$this->importCSVDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote_collection.csv');
$footnotes = $this->repository->getFootnotesByUids([2, 4]);
$this->assertCount(2, $footnotes);
$this->assertSame(2, $footnotes[0]->getUid());
Expand All @@ -108,7 +108,7 @@ public function testShouldGetFootnotesByUids(): void

public function testShouldSortFootnotesByGivenOrderOfUids(): void
{
$this->importDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote_collection.xml');
$this->importCSVDataSet(__DIR__ . '/fixtures/tx_happyfeet_domain_model_footnote_collection.csv');
$footnotes = $this->repository->getFootnotesByUids([4, 1, 5, 3, 2]);
$this->assertCount(5, $footnotes);
$this->assertSame(4, $footnotes[0]->getUid());
Expand All @@ -134,7 +134,7 @@ public function testShouldAddObject(): void
try {
$footnote = new Footnote();
$this->repository->add($footnote);
} catch (Throwable $throwable) {
} catch (Throwable) {
$this->fail('assert that no exception is thrown.');
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tx_happyfeet_domain_model_footnote,,,,,,,,
,uid,pid,l18n_diffsource,index_number,title,header,description,deleted
,1,1,,2,0,test,,0

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tx_happyfeet_domain_model_footnote,,,,,,,,
,uid,pid,l18n_diffsource,index_number,title,header,description,deleted
,1,1,,1,0,,,0
,2,1,,2,0,,,0
,3,1,,2,0,,,0
,4,1,,2,0,,,0
,5,1,,2,0,,,0
,6,1,,2,0,,,0
Loading

0 comments on commit a585493

Please sign in to comment.