diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 89e8fb98..c0eb173d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -134,7 +134,7 @@ jobs: - uses: cachix/install-nix-action@v31 with: - nix_path: nixpkgs=channel:nixos-unstable + nix_path: nixpkgs=channel:nixos-26.05 - name: Run Acceptance Tests PHP8.2 run: nix-shell --arg phpVersion \"php82\" --pure --run project-test-acceptance diff --git a/Classes/Domain/Repository/CategoryRepository.php b/Classes/Domain/Repository/CategoryRepository.php index b1b5e3d8..2e45480d 100644 --- a/Classes/Domain/Repository/CategoryRepository.php +++ b/Classes/Domain/Repository/CategoryRepository.php @@ -28,6 +28,9 @@ public function findAllAsArray(?Category $selectedCategory = null): array $categories = []; // Transform categories to array foreach ($localCategories as $localCategory) { + if (($localCategory instanceof Category) === false) { + continue; + } $newCategory = [ 'uid' => $localCategory->getUid(), 'title' => $localCategory->getTitle(), diff --git a/Classes/Hooks/DataHandler.php b/Classes/Hooks/DataHandler.php index 54add3eb..b0c151b8 100644 --- a/Classes/Hooks/DataHandler.php +++ b/Classes/Hooks/DataHandler.php @@ -14,6 +14,7 @@ class DataHandler { public function __construct(private readonly CacheManager $cacheManager) {} + /** * Flushes the cache if a news record was edited. * This happens on two levels: by UID and by PID. diff --git a/Configuration/Services.php b/Configuration/Services.php index 0e32bd65..f00568f1 100644 --- a/Configuration/Services.php +++ b/Configuration/Services.php @@ -2,8 +2,6 @@ declare(strict_types=1); -namespace Extcode\CartProducts\Configuration; - use Extcode\CartProducts\Handler\WatchlistItemHandler; use Extcode\CartProducts\Hooks\DataHandler; use Extcode\CartProducts\Reaction\UpdateStockReaction; diff --git a/Tests/Acceptance/Support/Environment.php b/Tests/Acceptance/Support/Environment.php index 1ef7acbd..b9eb9050 100644 --- a/Tests/Acceptance/Support/Environment.php +++ b/Tests/Acceptance/Support/Environment.php @@ -13,7 +13,7 @@ use Codappix\Typo3PhpDatasets\PhpDataSet; use Codeception\Event\SuiteEvent; -use TYPO3\TestingFramework\Core\Acceptance\Extension\BackendEnvironment; +use Extcode\TestingFramework\Core\Acceptance\Extension\BackendEnvironment; final class Environment extends BackendEnvironment { diff --git a/Tests/Acceptance/Support/Tester.php b/Tests/Acceptance/Support/Tester.php index e353ed30..22db3a14 100644 --- a/Tests/Acceptance/Support/Tester.php +++ b/Tests/Acceptance/Support/Tester.php @@ -13,7 +13,6 @@ use Codeception\Actor; use Extcode\CartProducts\Tests\Acceptance\Support\_generated\TesterActions; -use TYPO3\TestingFramework\Core\Acceptance\Step\FrameSteps; /** * @method void wantToTest($text) @@ -31,7 +30,5 @@ class Tester extends Actor { use TesterActions; - use FrameSteps; - protected int $retryNum = 2; } diff --git a/composer.json b/composer.json index eaa57c17..a17b60af 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,9 @@ "typo3/class-alias-loader": true, "sbuerk/typo3-cmscomposerinstallers-testingframework-bridge": true, "phpstan/extension-installer": true - } + }, + "lock": false, + "sort-packages": true }, "extra": { "typo3/cms": { @@ -48,13 +50,10 @@ "web-dir": ".build/public" } }, - "version": "8.0.0", - "minimum-stability": "dev", - "prefer-stable": true, "require": { "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", "ext-pdo": "*", - "extcode/cart": "dev-main as 12.0.0", + "extcode/cart": "^12.0", "typo3/cms-core": "^14.3", "typo3/cms-extbase": "^14.3", "typo3/cms-fluid": "^14.3" @@ -64,6 +63,7 @@ "codeception/codeception": "^5.0", "codeception/module-db": "^3.1", "codeception/module-webdriver": "^4.0", + "extcode/testing-framework": "dev-main", "friendsofphp/php-cs-fixer": "^3.64", "helmich/typo3-typoscript-lint": "^3.1", "phpstan/extension-installer": "^1.4", @@ -76,7 +76,6 @@ "typo3/cms-fluid-styled-content": "^14.3", "typo3/cms-install": "^14.3", "typo3/cms-reactions": "^14.3", - "typo3/testing-framework": "^9.3", "werkraummedia/watchlist": "^3.0", "ssch/typo3-rector": "^3.11" }, diff --git a/ext_localconf.php b/ext_localconf.php index 10d4af61..ce59193e 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -5,94 +5,114 @@ use Extcode\CartProducts\Controller\ProductController; use Extcode\CartProducts\Hooks\DataHandler; use Extcode\CartProducts\Hooks\DatamapDataHandlerHook; -use TYPO3\CMS\Extbase\Domain\Model\Category; +use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Extbase\Utility\ExtensionUtility; -$_LLL_be = 'LLL:EXT:cart_products/Resources/Private/Language/locallang_be.xlf:'; - -// configure plugins -ExtensionUtility::configurePlugin( - 'cart_products', - 'ShowProduct', - [ - ProductController::class => 'show, showForm', - ], - [ - ProductController::class => 'showForm', - ], - ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT -); - -ExtensionUtility::configurePlugin( - 'cart_products', - 'ListProducts', - [ - ProductController::class => 'list, show, showForm', - ], - [ - ProductController::class => 'showForm', - ], - ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT -); - -ExtensionUtility::configurePlugin( - 'cart_products', - 'TeaserProducts', - [ - ProductController::class => 'teaser, showForm', - ], - [ - ProductController::class => 'showForm', - ], - ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT -); - -ExtensionUtility::configurePlugin( - 'cart_products', - 'SingleProduct', - [ - ProductController::class => 'show, showForm', - ], - [ - ProductController::class => 'showForm', - ], - ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT -); - -ExtensionUtility::configurePlugin( - 'cart_products', - 'ProductPartial', - [ - ProductController::class => 'showForm', - ], - [ - ProductController::class => 'showForm', - ], - ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT -); - -// Cart Hooks - -// processDatamapClass Hook - -$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['cartproducts_allowed'] - = DatamapDataHandlerHook::class; - -// clearCachePostProc Hook - -$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']['cartproducts_clearcache'] - = DataHandler::class . '->clearCachePostProc'; - -// register "cartproducts:" namespace -$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['cartproducts'][] - = 'Extcode\\CartProducts\\ViewHelpers'; - -// register listTemplateLayouts -$GLOBALS['TYPO3_CONF_VARS']['EXT']['cart_products']['templateLayouts']['list_products'][] = [$_LLL_be . 'flexforms_template.templateLayout.table', 'table']; -$GLOBALS['TYPO3_CONF_VARS']['EXT']['cart_products']['templateLayouts']['list_products'][] = [$_LLL_be . 'flexforms_template.templateLayout.grid', 'grid']; -$GLOBALS['TYPO3_CONF_VARS']['EXT']['cart_products']['templateLayouts']['teaser_products'][] = [$_LLL_be . 'flexforms_template.templateLayout.table', 'table']; -$GLOBALS['TYPO3_CONF_VARS']['EXT']['cart_products']['templateLayouts']['teaser_products'][] = [$_LLL_be . 'flexforms_template.templateLayout.grid', 'grid']; - -$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][Category::class] = [ - 'className' => \Extcode\CartProducts\Domain\Model\Category::class, -]; +(static function (string $extKey): void { + $_LLL_be = 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_be.xlf:'; + + if (is_array($GLOBALS['TYPO3_CONF_VARS'] ?? null) === false) { + throw new \Exception('$GLOBALS[\'TYPO3_CONF_VARS\'] is not an array', 1774601240); + } + + ArrayUtility::mergeRecursiveWithOverrule( + $GLOBALS['TYPO3_CONF_VARS'], + [ + 'EXT' => [ + $extKey => [ + 'templateLayouts' => [ + 'list_products' => [ + 'table' => [$_LLL_be . 'flexforms_template.templateLayout.table', 'table'], + 'grid' => [$_LLL_be . 'flexforms_template.templateLayout.grid', 'grid'], + ], + 'teaser_products' => [ + 'table' => [$_LLL_be . 'flexforms_template.templateLayout.table', 'table'], + 'grid' => [$_LLL_be . 'flexforms_template.templateLayout.grid', 'grid'], + ], + ], + ], + ], + 'SC_OPTIONS' => [ + 't3lib/class.t3lib_tcemain.php' => [ + 'processDatamapClass' => [ + 'cartproducts_allowed' => DatamapDataHandlerHook::class, + ], + 'clearCachePostProc' => [ + 'cartproducts_clearcache' => DataHandler::class . '->clearCachePostProc', + ], + ], + ], + 'SYS' => [ + 'fluid' => [ + 'namespaces' => [ + 'cartproducts' => [ + 1 => 'Extcode\\CartProducts\\ViewHelpers', + ], + ], + ], + ], + ] + ); + + // configure plugins + ExtensionUtility::configurePlugin( + 'cart_products', + 'ShowProduct', + [ + ProductController::class => 'show, showForm', + ], + [ + ProductController::class => 'showForm', + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); + + ExtensionUtility::configurePlugin( + 'cart_products', + 'ListProducts', + [ + ProductController::class => 'list, show, showForm', + ], + [ + ProductController::class => 'showForm', + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); + + ExtensionUtility::configurePlugin( + 'cart_products', + 'TeaserProducts', + [ + ProductController::class => 'teaser, showForm', + ], + [ + ProductController::class => 'showForm', + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); + + ExtensionUtility::configurePlugin( + 'cart_products', + 'SingleProduct', + [ + ProductController::class => 'show, showForm', + ], + [ + ProductController::class => 'showForm', + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); + + ExtensionUtility::configurePlugin( + 'cart_products', + 'ProductPartial', + [ + ProductController::class => 'showForm', + ], + [ + ProductController::class => 'showForm', + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); + +})('cart_products'); diff --git a/shell.nix b/shell.nix index 0b95c185..11ed21e4 100644 --- a/shell.nix +++ b/shell.nix @@ -148,6 +148,7 @@ let in pkgs.mkShellNoCC { name = "TYPO3 Extension extcode/cart-products"; buildInputs = [ + pkgs.cacert php composer projectInstall