Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add support for TYPO3 13.0 #22

Merged
merged 16 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ jobs:
fail-fast: false
matrix:
php-version: ["8.1", "8.2", "8.3"]
typo3-version: ["11.5", "12.4"]
typo3-version: ["11.5", "12.4", "13.0"]
dependencies: ["highest", "lowest"]
exclude:
- php-version: "8.1"
typo3-version: "13.0"
env:
typo3DatabaseName: typo3
typo3DatabaseHost: '127.0.0.1'
Expand Down
4 changes: 2 additions & 2 deletions Classes/Cache/SitemapsCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function get(

return array_values(
array_map(
static fn(string $sitemapUrl) => new Domain\Model\Sitemap(
static fn (string $sitemapUrl) => new Domain\Model\Sitemap(
new Core\Http\Uri($sitemapUrl),
$site,
$siteLanguage ?? $site->getDefaultLanguage(),
Expand Down Expand Up @@ -96,7 +96,7 @@ public function set(array $sitemaps): void
$this->writeCache(
$cacheIdentifier,
array_map(
static fn(Domain\Model\Sitemap $sitemap) => (string)$sitemap->getUri(),
static fn (Domain\Model\Sitemap $sitemap) => (string)$sitemap->getUri(),
$sitemapsOfCurrentSite,
),
);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/LocateSitemapsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected function interact(Console\Input\InputInterface $input, Console\Output\
$site->getDefaultLanguage()->getLanguageId(),
);
$question->setValidator(
fn(string|int $siteLanguage) => $this->validateSiteLanguage($siteLanguage, $site, $availableSiteLanguages),
fn (string|int $siteLanguage) => $this->validateSiteLanguage($siteLanguage, $site, $availableSiteLanguages),
);

$input->setOption(
Expand Down
21 changes: 19 additions & 2 deletions Classes/Form/Element/XmlSitemapLocationElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,23 @@ final class XmlSitemapLocationElement extends Backend\Form\Element\AbstractFormE
],
];

/**
* @todo Make private readonly Core\Imaging\IconFactory once support for TYPO3 v12 is dropped
*/
protected $iconFactory;
private readonly Core\Site\SiteFinder $siteFinder;
private readonly Sitemap\SitemapLocator $sitemapLocator;

/**
* @todo Use DI once support for TYPO3 v12 is dropped
*/
public function __construct(Backend\Form\NodeFactory $nodeFactory = null, array $data = [])
{
parent::__construct($nodeFactory, $data);
if ((new Core\Information\Typo3Version())->getMajorVersion() < 13) {
parent::__construct($nodeFactory, $data);
} else {
$this->iconFactory = Core\Utility\GeneralUtility::makeInstance(Core\Imaging\IconFactory::class);
}

$this->siteFinder = Core\Utility\GeneralUtility::makeInstance(Core\Site\SiteFinder::class);
$this->sitemapLocator = Core\Utility\GeneralUtility::makeInstance(Sitemap\SitemapLocator::class);
Expand Down Expand Up @@ -211,7 +222,13 @@ private function renderCallout(string $state, string $icon, string $body, bool $

private function renderIcon(string $identifier): string
{
return $this->iconFactory->getIcon($identifier, Core\Imaging\Icon::SIZE_SMALL)->render();
if (enum_exists(Core\Imaging\IconSize::class)) {
$iconSize = Core\Imaging\IconSize::SMALL;
} else {
$iconSize = Core\Imaging\Icon::SIZE_SMALL;
}

return $this->iconFactory->getIcon($identifier, $iconSize)->render();
}

private function translate(string $key): string
Expand Down
2 changes: 1 addition & 1 deletion Classes/Sitemap/Provider/RobotsTxtProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function get(

return array_values(
array_map(
static fn(string $url) => new Domain\Model\Sitemap(
static fn (string $url) => new Domain\Model\Sitemap(
new Core\Http\Uri($url),
$site,
$siteLanguage ?? $site->getDefaultLanguage(),
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use EliasHaeussler\Typo3SitemapLocator\Sitemap;
use Symfony\Component\DependencyInjection;

return static function (DependencyInjection\ContainerBuilder $container): void {
return static function(DependencyInjection\ContainerBuilder $container): void {
$container->registerForAutoconfiguration(Sitemap\Provider\Provider::class)
->addTag('sitemap_locator.sitemap_provider');
};
14 changes: 8 additions & 6 deletions Documentation/Installation/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Requirements
============

- PHP 8.1 - 8.3
- TYPO3 11.5 LTS - 12.4 LTS
- TYPO3 11.5 LTS - 13.0

.. _steps:

Expand All @@ -33,8 +33,10 @@ Or download it from the
Version matrix
==============

+--------------------+-------------------------+---------------+
| Extension versions | TYPO3 versions | PHP versions |
+====================+=========================+===============+
| **since 0.1.0** | **11.5 LTS - 12.4 LTS** | **8.1 - 8.3** |
+--------------------+-------------------------+---------------+
+--------------------+---------------------+---------------+
| Extension versions | TYPO3 versions | PHP versions |
+====================+=====================+===============+
| **since 0.1.3** | **11.5 LTS - 13.0** | **8.1 - 8.3** |
+--------------------+---------------------+---------------+
| 0.1.0 - 0.1.2 | 11.5 LTS - 12.4 LTS | 8.1 - 8.3 |
+--------------------+---------------------+---------------+
4 changes: 2 additions & 2 deletions Tests/Functional/Command/LocateSitemapsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ protected function setUp(): void
$this->importCSVDataSet(\dirname(__DIR__) . '/Fixtures/Database/be_users.csv');
$this->importCSVDataSet(\dirname(__DIR__) . '/Fixtures/Database/pages.csv');

$this->setUpBackendUser(1);
Core\Core\Bootstrap::initializeLanguageObject();
$backendUser = $this->setUpBackendUser(1);
$GLOBALS['LANG'] = $this->get(Core\Localization\LanguageServiceFactory::class)->createFromUserPreferences($backendUser);

$this->cache->flush();
}
Expand Down
16 changes: 12 additions & 4 deletions Tests/Functional/SiteTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,23 @@ trait SiteTrait
private function createSite(string $baseUrl = 'https://typo3-testing.local/'): Core\Site\Entity\Site
{
$configPath = $this->instancePath . '/typo3conf/sites';
$typo3Version = new Core\Information\Typo3Version();

// @todo Remove once support for TYPO3 v11 is dropped
if ((new Core\Information\Typo3Version())->getMajorVersion() < 12) {
$siteConfiguration = new Core\Configuration\SiteConfiguration($configPath);
} else {
if ($typo3Version->getMajorVersion() >= 13) {
$siteConfiguration = new Core\Configuration\SiteConfiguration(
$configPath,
new Core\EventDispatcher\NoopEventDispatcher(),
new Core\Cache\Frontend\NullFrontend('core'),
);
} elseif (($typo3Version)->getMajorVersion() >= 12) {
// @todo Remove once support for TYPO3 v12 is dropped
$siteConfiguration = new Core\Configuration\SiteConfiguration(
$configPath,
new Core\EventDispatcher\NoopEventDispatcher(),
);
} else {
// @todo Remove once support for TYPO3 v11 is dropped
$siteConfiguration = new Core\Configuration\SiteConfiguration($configPath);
}

$siteConfiguration->createNewBasicSite(static::$testSiteIdentifier, 1, $baseUrl);
Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/Sitemap/SitemapLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function locateBySiteDispatchesEventWithLocatedSitemap(): void

$this->eventDispatcher->addListener(
Src\Event\SitemapsLocatedEvent::class,
static function (Src\Event\SitemapsLocatedEvent $event) use ($site, $expected): void {
static function(Src\Event\SitemapsLocatedEvent $event) use ($site, $expected): void {
self::assertSame($site, $event->getSite());
self::assertNull($event->getSiteLanguage());
self::assertEquals($expected, $event->getSitemaps());
Expand Down Expand Up @@ -289,7 +289,7 @@ public function isValidSitemapDispatchesEventWithValidityResult(): void

$this->eventDispatcher->addListener(
Src\Event\SitemapValidatedEvent::class,
static function (Src\Event\SitemapValidatedEvent $event) use ($sitemap): void {
static function(Src\Event\SitemapValidatedEvent $event) use ($sitemap): void {
self::assertSame($sitemap, $event->getSitemap());
self::assertTrue($event->isValid());

Expand Down
7 changes: 3 additions & 4 deletions Tests/Functional/Utility/BackendUtilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

use EliasHaeussler\Typo3SitemapLocator as Src;
use PHPUnit\Framework;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core;
use TYPO3\TestingFramework;

/**
Expand All @@ -44,9 +44,8 @@ protected function setUp(): void
$this->importCSVDataSet(\dirname(__DIR__) . '/Fixtures/Database/be_users.csv');
$this->importCSVDataSet(\dirname(__DIR__) . '/Fixtures/Database/pages.csv');

$this->setUpBackendUser(1);

Bootstrap::initializeLanguageObject();
$backendUser = $this->setUpBackendUser(1);
$GLOBALS['LANG'] = $this->get(Core\Localization\LanguageServiceFactory::class)->createFromUserPreferences($backendUser);
}

#[Framework\Attributes\Test]
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
"guzzlehttp/guzzle": "^7.0",
"psr/event-dispatcher": "^1.0",
"psr/http-message": "^1.0 || ^2.0",
"symfony/console": "^5.4 || ^6.0",
"symfony/dependency-injection": "^5.4 || ^6.0",
"typo3/cms-backend": "~11.5.4 || ~12.4.0",
"typo3/cms-core": "~11.5.4 || ~12.4.0"
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"typo3/cms-backend": "~11.5.4 || ~12.4.0 || ~13.0.0",
"typo3/cms-core": "~11.5.4 || ~12.4.0 || ~13.0.0"
},
"require-dev": {
"armin/editorconfig-cli": "^1.6 || ^2.0",
"eliashaeussler/php-cs-fixer-config": "^1.2 || ^2.0",
"eliashaeussler/php-cs-fixer-config": "^2.0",
"eliashaeussler/phpstan-config": "^2.2",
"eliashaeussler/rector-config": "^3.0",
"ergebnis/composer-normalize": "^2.39",
Expand All @@ -34,10 +34,10 @@
"phpunit/phpunit": "^10.1 || ^11.0",
"saschaegerer/phpstan-typo3": "^1.9",
"ssch/typo3-rector": "^2.0",
"symfony/event-dispatcher": "^5.4 || ^6.0",
"typo3/cms-seo": "~11.5.4 || ~12.4.0",
"typo3/coding-standards": "^0.7.1",
"typo3/testing-framework": "^7.0.2 || ^8.0.1"
"symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0",
"typo3/cms-seo": "~11.5.4 || ~12.4.0 || ~13.0.0",
"typo3/coding-standards": "^0.8.0@dev",
"typo3/testing-framework": "^7.0.2 || ^8.0.9"
},
"autoload": {
"psr-4": {
Expand Down
51 changes: 27 additions & 24 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dependency-checker.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"ext_*.php",
"Configuration/SiteConfiguration/Overrides/*.php",
"Configuration/*.php"
],
"symbol-whitelist": [
"TYPO3\\CMS\\Core\\Imaging\\IconSize"
]
}
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
'author_email' => '[email protected]',
'constraints' => [
'depends' => [
'typo3' => '11.5.4-12.4.99',
'typo3' => '11.5.4-13.0.99',
'php' => '8.1.0-8.3.99',
],
],
Expand Down
7 changes: 6 additions & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ parameters:
ignoreErrors:
-
message: """
#^Access to deprecated property \\$iconFactory of class TYPO3\\\\CMS\\\\Backend\\\\Form\\\\Element\\\\AbstractFormElement\\:
#^Access to deprecated property \\$iconFactory of class EliasHaeussler\\\\Typo3SitemapLocator\\\\Form\\\\Element\\\\XmlSitemapLocationElement\\:
since TYPO3 v12\\.4\\. will be removed in TYPO3 v13\\.0\\.$#
"""
count: 1
path: Classes/Form/Element/XmlSitemapLocationElement.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Imaging\\\\IconSize not found\\.$#"
count: 1
path: Classes/Form/Element/XmlSitemapLocationElement.php

-
message: "#^Method EliasHaeussler\\\\Typo3SitemapLocator\\\\Form\\\\Element\\\\XmlSitemapLocationElement\\:\\:__construct\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use Rector\Symfony\Symfony53\Rector\Class_\CommandDescriptionToPropertyRector;
use Rector\ValueObject\PhpVersion;

return static function (RectorConfig $rectorConfig): void {
return static function(RectorConfig $rectorConfig): void {
Config::create($rectorConfig, PhpVersion::PHP_81)
->in(
__DIR__ . '/Classes',
Expand Down
Loading