Skip to content

Commit

Permalink
Merge pull request #15 from AOEpeople/feature/TYPO3_12
Browse files Browse the repository at this point in the history
feat: TYPO3 v12 compatibility
  • Loading branch information
sourcesoldier authored Aug 30, 2024
2 parents c6476e7 + 3b176be commit 33f5745
Show file tree
Hide file tree
Showing 66 changed files with 228 additions and 421 deletions.
12 changes: 0 additions & 12 deletions .code-quality/phpstan-baseline.neon

This file was deleted.

30 changes: 0 additions & 30 deletions .code-quality/rector-8_0.php

This file was deleted.

24 changes: 12 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
strategy:
fail-fast: false
matrix:
typo3: [ ^11.5 ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
typo3: [ ^12.4 ]
php: [ '8.1', '8.2', '8.3' ]
steps:

- name: Checkout
Expand All @@ -38,32 +38,32 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies with nimut/typo3-complete:${{ matrix.typo3 }}
- name: Install dependencies with typo3/testing-framework
run: |
composer require --dev nimut/typo3-complete:${{ matrix.typo3 }} --no-progress
composer require --dev typo3/testing-framework --no-progress
git checkout composer.json
ln -nfs .Build/vendor/typo3/cms/typo3 typo3
- name: Lint PHP
run: find . -name \*.php ! -path "./.Build/*" ! -path "./scripts/*" ! -path "./typo3_src/*" | parallel --gnu php -d display_errors=stderr -l {} > /dev/null \;

- name: Unit Tests without coverage
if: matrix.typo3 != '^11.5' || matrix.php != '8.3'
if: matrix.typo3 == '^12.4' || matrix.php != '8.3'
run: |
export "UNIT_XML"=.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml
.Build/bin/phpunit --colors -c $UNIT_XML Tests/Unit
- name: Unit Tests with coverage
if: matrix.typo3 == '^11.5' && matrix.php == '8.3'
if: matrix.typo3 == '^12.4' && matrix.php == '8.3'
run: |
export "UNIT_XML"=.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests-v10.xml
export "UNIT_XML"=.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml
.Build/bin/phpunit --coverage-filter Classes --coverage-clover=unittest-coverage.clover --colors -c $UNIT_XML Tests/Unit/
- name: Functional Tests without coverage
run: |
export "FUNCTIONAL_XML"=.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml
.Build/bin/phpunit --colors -c $FUNCTIONAL_XML Tests/Functional
if: matrix.typo3 != '^11.5' || matrix.php != '8.3'
if: matrix.typo3 == '^12.4' || matrix.php != '8.3'
env:
typo3DatabaseHost: 127.0.0.1
typo3DatabaseName: typo3
Expand All @@ -72,9 +72,9 @@ jobs:

- name: Functional Tests with coverage
run: |
export "FUNCTIONAL_XML"=.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests-v10.xml
export "FUNCTIONAL_XML"=.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml
find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo "Running functional test suite {}"; .Build/bin/phpunit --coverage-filter Classes --coverage-clover={}functionaltest-coverage.clover --colors -c $FUNCTIONAL_XML {}'
if: matrix.typo3 == '^11.5' && matrix.php == '8.3'
if: matrix.typo3 == '^12.4' && matrix.php == '8.3'
env:
typo3DatabaseHost: 127.0.0.1
typo3DatabaseName: typo3
Expand All @@ -83,6 +83,6 @@ jobs:

- name: Upload functional coverage results to Scrutinizer
uses: sudo-bot/action-scrutinizer@latest
if: matrix.typo3 == '^11.5' && matrix.php == '8.3'
if: matrix.typo3 == '^12.4' && matrix.php == '8.3'
with:
cli-args: "--format=php-clover functional-coverage.clover --revision=${{ github.event.pull_request.head.sha || github.sha }}"
cli-args: "--format=php-clover .Build/reports/php_all_tests/coverage_clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}"
3 changes: 3 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
build:
nodes:
analysis:
image: default-bionic
environment:
php: 8.3.0
tests:
override:
- php-scrutinizer-run
Expand Down
12 changes: 5 additions & 7 deletions Classes/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand All @@ -32,22 +32,20 @@

abstract class AbstractCommand extends Command
{
protected FeatureFlagService $featureFlagService;

protected SymfonyStyle $inputOutput;

public function __construct(FeatureFlagService $featureFlagService)
{
public function __construct(
protected FeatureFlagService $featureFlagService
) {
parent::__construct();
$this->featureFlagService = $featureFlagService;
}

/**
* Enable or disable features. $features can be a comma-separated list of feature names
*/
protected function setFeatureStatus(string $features, bool $enabled): void
{
$features = array_map('trim', explode(',', $features));
$features = array_map(trim(...), explode(',', $features));
foreach ($features as $feature) {
$info = ($enabled) ? 'Activate' : 'Deactivate';
$this->showInfo($info . ' feature: ' . $feature);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/ActivateFeatureFlagCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/DeactivateFeatureFlagCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/ToggleRecordsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/FeatureFlag.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down
14 changes: 5 additions & 9 deletions Classes/Domain/Repository/FeatureFlagRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand All @@ -29,19 +29,15 @@
use Aoe\FeatureFlag\Service\FeatureFlagService;
use Aoe\FeatureFlag\System\Db\FeatureFlagData;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Extbase\Persistence\Repository;

class FeatureFlagRepository extends Repository
{
private FeatureFlagData $featureFlagData;

public function __construct(FeatureFlagData $featureFlagData)
{
$this->featureFlagData = $featureFlagData;
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
parent::__construct($objectManager);
public function __construct(
private readonly FeatureFlagData $featureFlagData
) {
parent::__construct();
}

public function initializeObject(): void
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Repository/MappingRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Form/Element/AbstractFormSelectElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Form/Element/FeatureFlagFormSelectElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Form/Element/InfoTextElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Service/Exception/FeatureNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down
17 changes: 4 additions & 13 deletions Classes/Service/FeatureFlagService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down Expand Up @@ -44,22 +44,13 @@ class FeatureFlagService
*/
public const BEHAVIOR_SHOW = 1;

private FeatureFlagRepository $featureFlagRepository;

private PersistenceManagerInterface $persistenceManager;

private Configuration $configuration;

private array $cachedFlags = [];

public function __construct(
FeatureFlagRepository $featureFlagRepository,
PersistenceManagerInterface $persistenceManager,
Configuration $configuration
private readonly FeatureFlagRepository $featureFlagRepository,
private readonly PersistenceManagerInterface $persistenceManager,
private readonly Configuration $configuration
) {
$this->featureFlagRepository = $featureFlagRepository;
$this->persistenceManager = $persistenceManager;
$this->configuration = $configuration;
}

public function isFeatureEnabled(string $flag): bool
Expand Down
10 changes: 5 additions & 5 deletions Classes/System/Db/FeatureFlagData.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down Expand Up @@ -59,7 +59,7 @@ public function getContentElements(string $table, int $behavior, int $enabled):
->from(self::TABLE_FLAGS)
->where(
$queryBuilder->expr()
->andX(
->and(
$queryBuilder->expr()
->eq(
self::TABLE_MAPPING . '.feature_flag',
Expand Down Expand Up @@ -88,7 +88,7 @@ public function getContentElements(string $table, int $behavior, int $enabled):
)
);

return $queryBuilder->execute()
return $queryBuilder->executeQuery()
->fetchAllAssociative();
}

Expand All @@ -106,7 +106,7 @@ public function updateContentElements(string $table, array $uids, bool $isVisibl
->set('hidden', $isVisible ? 0 : 1)
->add('where', $queryBuilder->expr()->in('uid', $uids));

$query->execute();
$query->executeStatement();
}

public function getContentElementsPIDs(string $table, int $uid): string
Expand All @@ -129,7 +129,7 @@ public function getContentElementsPIDs(string $table, int $uid): string
)
);

return $query->execute()
return $query->executeQuery()
->fetchOne();
}
}
4 changes: 2 additions & 2 deletions Classes/System/Typo3/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down Expand Up @@ -49,7 +49,7 @@ public function __construct(ExtensionConfiguration $extensionConfiguration)

public function getTables(): array
{
return explode(',', $this->get(self::CONF_TABLES));
return explode(',', (string) $this->get(self::CONF_TABLES));
}

/**
Expand Down
Loading

0 comments on commit 33f5745

Please sign in to comment.