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
29 changes: 21 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- 8.2
- 8.3
- 8.4
- 8.5
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -60,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 @@ -70,11 +71,13 @@ jobs:
matrix:
include:
- php-version: '8.2'
typo3-version: '^13.4'
typo3-version: '^14.2'
- php-version: '8.3'
typo3-version: '^13.4'
typo3-version: '^14.2'
- php-version: '8.4'
typo3-version: '^13.4'
typo3-version: '^14.2'
- php-version: '8.5'
typo3-version: '^14.2'
steps:
- uses: actions/checkout@v4

Expand All @@ -89,12 +92,12 @@ 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
Expand All @@ -118,6 +121,9 @@ jobs:
- name: Run Unit Tests PHP8.4
run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-unit

- name: Run Unit Tests PHP8.5
run: nix-shell --arg phpVersion \"php85\" --pure --run project-test-unit

- name: Run Functional Tests PHP8.2
run: nix-shell --arg phpVersion \"php82\" --pure --run project-test-functional

Expand All @@ -127,10 +133,13 @@ jobs:
- name: Run Functional Tests PHP8.4
run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-functional

- name: Run Functional Tests PHP8.5
run: nix-shell --arg phpVersion \"php85\" --pure --run project-test-functional

test-acceptance:
runs-on: ubuntu-latest
needs:
- test-php
- test-unit-and-functional
steps:
- uses: actions/checkout@v3

Expand All @@ -149,3 +158,7 @@ jobs:

- name: Run Acceptance Tests PHP8.4
run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-acceptance

- name: Run Acceptance Tests PHP8.5
run: nix-shell --arg phpVersion \"php85\" --pure --run project-test-acceptance

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
3 changes: 1 addition & 2 deletions Build/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ parameters:
- ../Classes
- ../Configuration
- ../Tests
- ../ext_emconf.php
- ../ext_localconf.php
excludePaths:
- '../Tests/Acceptance/Support/_generated/TesterActions.php'
- ../Tests/Acceptance/Support/_generated

disallowedFunctionCalls:
-
Expand Down
2 changes: 1 addition & 1 deletion Build/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?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" backupGlobals="true" bootstrap="../.build/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">
<coverage/>
<testsuites>
<testsuite name="functional">
Expand Down
15 changes: 8 additions & 7 deletions Classes/Controller/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

use Exception;
use Extcode\Cart\Domain\Model\Cart\Cart;
use Extcode\Cart\Service\SessionHandler;
Expand All @@ -25,11 +24,13 @@
use Extcode\CartEvents\Domain\Repository\EventRepository;
use Extcode\CartEvents\Domain\Repository\PriceCategoryRepository;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Cache\CacheTag;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Annotation\IgnoreValidation;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Http\ForwardResponse;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManagerInterface;

final class EventController extends ActionController
{
Expand All @@ -56,7 +57,7 @@ protected function initializeAction(): void
static $cacheTagsSet = false;

if (!$cacheTagsSet) {
$GLOBALS['TSFE']->addCacheTags(['tx_cartevents']);
$this->request->getAttribute('frontend.cache.collector')->addCacheTags(new CacheTag('tx_cartevents', 3600));
$cacheTagsSet = true;
}
}
Expand Down Expand Up @@ -102,8 +103,8 @@ public function teaserAction(): ResponseInterface

public function showAction(?Event $event = null): ResponseInterface
{
if ((int)$GLOBALS['TSFE']->page['doktype'] === 186) {
$eventUid = (int)$GLOBALS['TSFE']->page['cart_events_event'];
if ((int)$this->request->getAttribute('frontend.page.information')->getPageRecord()['doktype'] === 186) {
$eventUid = (int)$this->request->getAttribute('frontend.page.information')->getPageRecord()['cart_events_event'];
$event = $this->eventRepository->findByUid($eventUid);
}

Expand All @@ -120,8 +121,8 @@ public function showAction(?Event $event = null): ResponseInterface
#[IgnoreValidation(['value' => 'priceCategory'])]
public function formAction(?EventDate $eventDate = null, ?PriceCategory $priceCategory = null): ResponseInterface
{
if (class_exists(\TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManagerInterface::class) === false) {
throw new \BadFunctionCallException('This action requires the installation of typo3/cms-form.');
if (class_exists(FormPersistenceManagerInterface::class) === false) {
throw new \BadFunctionCallException('This action requires the installation of typo3/cms-form.', 2153916883);
}

if (!$eventDate) {
Expand All @@ -142,7 +143,7 @@ public function formAction(?EventDate $eventDate = null, ?PriceCategory $priceCa
}
$formDefinition = $event->getFormDefinition();
$formPersistenceManager = GeneralUtility::makeInstance(
\TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManagerInterface::class
FormPersistenceManagerInterface::class
);
$form = $formPersistenceManager->load($formDefinition);

Expand Down
4 changes: 2 additions & 2 deletions Classes/Controller/EventDateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

use Extcode\CartEvents\Domain\Repository\EventDateRepository;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Cache\CacheTag;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

Expand All @@ -28,7 +28,7 @@ protected function initializeAction(): void
static $cacheTagsSet = false;

if (!$cacheTagsSet) {
$GLOBALS['TSFE']->addCacheTags(['tx_cartevents']);
$this->request->getAttribute('frontend.cache.collector')->addCacheTags(new CacheTag('tx_cartevents', 3600));
$cacheTagsSet = true;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/Model/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class Event extends AbstractEntity

protected ?string $formDefinition = null;

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $sku = '';

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $title = '';

protected string $teaser = '';
Expand All @@ -54,7 +54,7 @@ class Event extends AbstractEntity
/**
* @var ObjectStorage<EventDate>
*/
#[Cascade(['value' => 'remove'])]
#[Cascade(value: 'remove')]
protected ObjectStorage $eventDates;

/**
Expand Down
10 changes: 5 additions & 5 deletions Classes/Domain/Model/EventDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class EventDate extends AbstractEventDate
{
protected Event $event;

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $sku = '';

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $title = '';

protected string $location = '';
Expand All @@ -49,15 +49,15 @@ class EventDate extends AbstractEventDate
/**
* @var ObjectStorage<SpecialPrice>
*/
#[Cascade(['value' => 'remove'])]
#[Cascade(value: 'remove')]
protected ObjectStorage $specialPrices;

protected bool $priceCategorized = false;

/**
* @var ObjectStorage<PriceCategory>
*/
#[Cascade(['value' => 'remove'])]
#[Cascade(value: 'remove')]
protected ObjectStorage $priceCategories;

protected bool $handleSeats = false;
Expand All @@ -71,7 +71,7 @@ class EventDate extends AbstractEventDate
/**
* @var ObjectStorage<CalendarEntry>
*/
#[Cascade(['value' => 'remove'])]
#[Cascade(value: 'remove')]
protected ObjectStorage $calendarEntries;

public function __construct()
Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/Model/PriceCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ class PriceCategory extends AbstractEntity
{
protected EventDate $eventDate;

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $sku = '';

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $title = '';

protected float $price = 0.0;

/**
* @var ObjectStorage<SpecialPrice>
*/
#[Cascade(['value' => 'remove'])]
#[Cascade(value: 'remove')]
protected ObjectStorage $specialPrices;

protected int $seatsNumber = 0;
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Model/SpecialPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

class SpecialPrice extends AbstractEntity
{
#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $title = '';

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected float $price = 0.0;

protected ?FrontendUserGroup $frontendUserGroup = null;
Expand Down
9 changes: 8 additions & 1 deletion Classes/Domain/Repository/EventDateRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@

class EventDateRepository extends Repository
{
/**
* Constructs a new Repository
*/
public function __construct(private readonly ConnectionPool $connectionPool)
{
parent::__construct();
}
public function findNext(int $limit, string $pidList): array
{
$table = 'tx_cartevents_domain_model_eventdate';
$joinTableEvent = 'tx_cartevents_domain_model_event';

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
$queryBuilder = $this->connectionPool
->getQueryBuilderForTable($table);

$queryBuilder
Expand Down
10 changes: 5 additions & 5 deletions Classes/EventListener/CheckProductAvailability.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Exception;
use Extcode\Cart\Domain\Model\Cart\Cart;
use Extcode\Cart\Domain\Model\Cart\Product;
use Extcode\Cart\Domain\Model\Cart\ProductInterface;
use Extcode\Cart\Event\CheckProductAvailabilityEvent;
use Extcode\CartEvents\Domain\Model\EventDate;
use Extcode\CartEvents\Domain\Model\PriceCategory;
Expand Down Expand Up @@ -67,7 +67,7 @@ public function __invoke(CheckProductAvailabilityEvent $listenerEvent): void
}
}

protected function retrieveEventDateFromDatabase(Product $cartProduct): void
protected function retrieveEventDateFromDatabase(ProductInterface $cartProduct): void
{
$querySettings = $this->eventDateRepository->createQuery()->getQuerySettings();
$querySettings->setRespectStoragePage(false);
Expand All @@ -80,7 +80,7 @@ protected function retrieveEventDateFromDatabase(Product $cartProduct): void
$this->eventDate = $eventDate;
}

protected function getQuantitiesFromRequest(Request $request, Product $cartProduct): mixed
protected function getQuantitiesFromRequest(Request $request, ProductInterface $cartProduct): mixed
{
if ($request->hasArgument('quantities')) {
$quantities = $request->getArgument('quantities');
Expand All @@ -102,7 +102,7 @@ protected function getQuantitiesFromRequest(Request $request, Product $cartProdu
}

protected function hasEventDateEnoughSeats(
Product $cartProduct,
ProductInterface $cartProduct,
Cart $cart,
string $mode,
int $quantity,
Expand All @@ -129,7 +129,7 @@ protected function hasEventDateEnoughSeats(
}

protected function hasPriceCategoryEnoughSeats(
Product $cartProduct,
ProductInterface $cartProduct,
Cart $cart,
string $mode,
string $beVariantId,
Expand Down
6 changes: 3 additions & 3 deletions Classes/EventListener/Order/Stock/FlushCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
use Extcode\CartEvents\Domain\Model\EventDate;
use Extcode\CartEvents\Domain\Repository\EventDateRepository;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;

readonly class FlushCache
{
public function __construct(
private EventDateRepository $eventDateRepository
private EventDateRepository $eventDateRepository,
private readonly CacheManager $cacheManager
) {}

public function __invoke(EventInterface $event): void
Expand All @@ -40,7 +40,7 @@ public function __invoke(EventInterface $event): void
throw new Exception('EventDate with uid ' . $cartProduct->getProductId() . ' has no event!', 1769617883);
}
$cacheTag = 'tx_cartevents_event_' . $event->getUid();
$cacheManager = GeneralUtility::makeInstance(CacheManager::class);
$cacheManager = $this->cacheManager;
$cacheManager->flushCachesInGroupByTag('pages', $cacheTag);
}
}
Expand Down
Loading
Loading