Skip to content
Open
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
26 changes: 13 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
run: composer install --prefer-dist --no-progress --no-suggest

- name: Coding Guideline
run: vendor/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./
run: .build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./

code-quality:
runs-on: ubuntu-latest
Expand All @@ -71,13 +71,13 @@ jobs:
matrix:
include:
- php-version: '8.2'
typo3-version: '^13.4'
typo3-version: '^14.1'
- php-version: '8.3'
typo3-version: '^13.4'
typo3-version: '^14.1'
- php-version: '8.4'
typo3-version: '^13.4'
typo3-version: '^14.1'
- php-version: '8.5'
typo3-version: '^13.4'
typo3-version: '^14.1'
steps:
- uses: actions/checkout@v4

Expand All @@ -92,20 +92,20 @@ jobs:
composer require --no-interaction --prefer-dist --no-progress "typo3/cms-core:${{ matrix.typo3-version }}" "typo3/cms-extbase:${{ matrix.typo3-version }}" "typo3/cms-frontend:${{ matrix.typo3-version }}"

- name: Build codeception tester
run: vendor/bin/codecept build
run: .build/bin/codecept build

- name: Code Quality (by PHPStan)
run: vendor/bin/phpstan analyse -c Build/phpstan.neon
run: .build/bin/phpstan analyse -c Build/phpstan.neon

test-php:
test-unit-and-functional:
runs-on: ubuntu-latest
needs:
- coding-guideline
- code-quality
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v5

- uses: cachix/install-nix-action@v17
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable

Expand Down Expand Up @@ -136,11 +136,11 @@ jobs:
test-acceptance:
runs-on: ubuntu-latest
needs:
- test-php
- test-unit-and-functional
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v5

- uses: cachix/install-nix-action@v17
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable

Expand Down
154 changes: 0 additions & 154 deletions .gitlab-ci.yml

This file was deleted.

5 changes: 5 additions & 0 deletions Build/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
(new PhpCsFixer\Finder())
->ignoreVCSIgnored(true)
->in(__DIR__ . '/../')
->exclude(
[
'var/',
]
)
)
->setRiskyAllowed(true)
->setRules([
Expand Down
1 change: 0 additions & 1 deletion Build/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ parameters:
- ../Classes
- ../Configuration
- ../Tests
- ../ext_emconf.php
- ../ext_localconf.php
excludePaths:
- ../Tests/Acceptance/Support/_generated
18 changes: 17 additions & 1 deletion Build/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" bootstrap="../vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php" colors="true" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache" requireCoverageMetadata="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
backupGlobals="true"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
cacheResult="false"
colors="true"
failOnDeprecation="true"
failOnWarning="true"
failOnRisky="true"
processIsolation="false"
requireCoverageMetadata="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
>
<coverage/>
<testsuites>
<testsuite name="functional">
Expand Down
22 changes: 22 additions & 0 deletions Classes/Constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace Extcode\CartProducts;

/*
* This file is part of the package extcode/cart-products
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

class Constants
{
/**
* Named constants for "magic numbers" of the field doktype.
*/
public const DOKTYPE_CARTPRODUCTS_PRODUCTS = 182;
public const DOKTYPE_CARTPRODUCTS_PRODUCT = 183;

}
40 changes: 6 additions & 34 deletions Classes/Controller/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ protected function initializeAction(): void
'Cart'
);

if (!empty($GLOBALS['TSFE']) && is_object($GLOBALS['TSFE'])) {
static $cacheTagsSet = false;

$typoScriptFrontendController = $GLOBALS['TSFE'];
if (!$cacheTagsSet) {
$typoScriptFrontendController->addCacheTags(['tx_cartproducts']);
$cacheTagsSet = true;
}
}

$this->settings['addToCartByAjax'] = isset($this->settings['addToCartByAjax']) ? (int)$this->settings['addToCartByAjax'] : 0;
}

Expand Down Expand Up @@ -125,7 +115,7 @@ protected function addCategoriesToDemandObjectFromSettings(ProductDemand $demand
protected function isActionAllowed(string $action): bool
{
$frameworkConfiguration = $this->configurationManager->getConfiguration($this->configurationManager::CONFIGURATION_TYPE_FRAMEWORK);
$allowedActions = $frameworkConfiguration['controllerConfiguration'][\Extcode\CartProducts\Controller\ProductController::class]['actions'] ?? [];
$allowedActions = $frameworkConfiguration['controllerConfiguration'][ProductController::class]['actions'] ?? [];

return in_array($action, $allowedActions, true);
}
Expand Down Expand Up @@ -178,14 +168,13 @@ public function listAction(int $currentPage = 1): ResponseInterface

$this->assignCurrencyTranslationData();

$this->addCacheTags($products);
return $this->htmlResponse();
}

public function showAction(?Product $product = null): ResponseInterface
{
if ((int)$GLOBALS['TSFE']->page['doktype'] === 183) {
$productUid = (int)$GLOBALS['TSFE']->page['cart_products_product'];
if ((int)$this->request->getAttribute('frontend.page.information')->getPageRecord()['doktype'] === 183) {
$productUid = (int)$this->request->getAttribute('frontend.page.information')->getPageRecord()['cart_products_product'];
$product = $this->productRepository->findByUid($productUid);
}

Expand All @@ -194,7 +183,6 @@ public function showAction(?Product $product = null): ResponseInterface

$this->assignCurrencyTranslationData();

$this->addCacheTags([$product]);
return $this->htmlResponse();
}

Expand All @@ -220,7 +208,6 @@ public function teaserAction(): ResponseInterface

$this->assignCurrencyTranslationData();

$this->addCacheTags($products);
return $this->htmlResponse();
}

Expand Down Expand Up @@ -254,17 +241,15 @@ protected function getProduct(): ?Product
*/
public function getProductUid(): mixed
{
if ((int)$GLOBALS['TSFE']->page['doktype'] === 183) {
return (int)$GLOBALS['TSFE']->page['cart_products_product'];
if ((int)$this->request->getAttribute('frontend.page.information')->getPageRecord()['doktype'] === 183) {
return (int)$this->request->getAttribute('frontend.page.information')->getPageRecord()['cart_products_product'];
}

if ($this->request->getPluginName() !== 'ProductPartial') {
return 0;
}

$configurationManager = GeneralUtility::makeInstance(
ConfigurationManager::class
);
$configurationManager = $this->configurationManager;
$configuration = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_FRAMEWORK);

$typoscriptService = GeneralUtility::makeInstance(
Expand Down Expand Up @@ -318,19 +303,6 @@ protected function assignCurrencyTranslationData()
$this->view->assign('currencyTranslationData', $currencyTranslationData);
}

protected function addCacheTags(iterable $products): void
{
$cacheTags = [];

foreach ($products as $product) {
// cache tag for each product record
$cacheTags[] = 'tx_cartproducts_product_' . $product->getUid();
}
if (count($cacheTags) > 0) {
$GLOBALS['TSFE']->addCacheTags($cacheTags);
}
}

protected function restoreSession(): void
{
$cart = $this->sessionHandler->restoreCart($this->cartConfiguration['settings']['cart']['pid']);
Expand Down
Loading
Loading