Skip to content

Commit 7b23da8

Browse files
committed
✨ inital commit
0 parents  commit 7b23da8

25 files changed

+3169
-0
lines changed

.editorconfig

+650
Large diffs are not rendered by default.

.github/workflows/tasks.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Tasks
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint-php:
7+
name: "php: ${{ matrix.php }} TYPO3: ${{ matrix.typo3 }}"
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
php: [ '8.2', '8.3' ]
13+
typo3: [ '11' ]
14+
steps:
15+
- name: Setup PHP with PECL extension
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: ${{ matrix.php }}
19+
- uses: actions/checkout@v3
20+
- uses: actions/cache@v3
21+
with:
22+
path: ~/.composer/cache/files
23+
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
24+
restore-keys: |
25+
${{ runner.os }}-${{ matrix.php }}-composer-
26+
- run: composer require typo3/minimal="^${{ matrix.typo3 }}" --dev --ignore-platform-req=php+
27+
- run: composer install --no-interaction --no-progress --ignore-platform-req=php+
28+
- run: ./vendor/bin/grumphp run --ansi

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/composer.lock
2+
/public/
3+
/vendor/
4+
/var
5+
/Resources/Public/test-results

Classes/Dto/SelectBy.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AUS\CacheAutomation\Dto;
6+
7+
final readonly class SelectBy
8+
{
9+
/** @var list<string> */
10+
public array $allFields;
11+
12+
/**
13+
* @param list<string> $startTimes
14+
* @param list<string> $endTimes
15+
* @param list<string> $filterByStartTimes
16+
*/
17+
public function __construct(
18+
public array $startTimes,
19+
public array $endTimes,
20+
public array $filterByStartTimes,
21+
) {
22+
$this->allFields = array_values(
23+
array_unique(
24+
[
25+
...$this->startTimes,
26+
...$this->endTimes,
27+
...$this->filterByStartTimes,
28+
]
29+
)
30+
);
31+
}
32+
}

Classes/Dto/SqlParseResult.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AUS\CacheAutomation\Dto;
6+
7+
final readonly class SqlParseResult
8+
{
9+
/**
10+
* @param list<string> $conditionalFields
11+
*/
12+
private function __construct(
13+
public string $mainTable,
14+
public array $conditionalFields,
15+
public bool $isRelational,
16+
) {
17+
}
18+
19+
/**
20+
* @param list<string> $conditionalFields
21+
*/
22+
public static function fromStrings(string $mainTable, array $conditionalFields, bool $isRelational): self
23+
{
24+
natcasesort($conditionalFields);
25+
$conditionalFields = array_values(array_unique($conditionalFields));
26+
27+
return new self(
28+
$mainTable,
29+
$conditionalFields,
30+
$isRelational
31+
);
32+
}
33+
34+
/**
35+
* @param array{mainTable: string, conditionalFields: list<string>, isRelational: bool} $array
36+
*/
37+
public static function __set_state(array $array): self
38+
{
39+
return new self(...$array);
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AUS\CacheAutomation\EventListener;
6+
7+
//use AUS\CacheAutomation\Service\AutoCacheTagService;
8+
//use TYPO3\CMS\Frontend\Event\AfterCacheableContentIsGeneratedEvent;
9+
10+
//final class AfterCacheableContentIsGeneratedEventListener
11+
//{
12+
// public function __invoke(AfterCacheableContentIsGeneratedEvent $event): void
13+
// {
14+
// AutoCacheTagService::getSingleton()->trigger();
15+
// }
16+
//}

Classes/Hooks/CustomTagFlusher.php

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AUS\CacheAutomation\Hooks;
6+
7+
use TYPO3\CMS\Core\Cache\CacheManager;
8+
use TYPO3\CMS\Core\DataHandling\DataHandler;
9+
use TYPO3\CMS\Core\Utility\GeneralUtility;
10+
use TYPO3\CMS\Core\Utility\MathUtility;
11+
12+
final class CustomTagFlusher
13+
{
14+
/** @var array<string, true> */
15+
private array $alreadyFlushed = [];
16+
17+
/**
18+
* @param array<string, mixed> $fieldArray
19+
* phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
20+
*/
21+
22+
public function processDatamap_afterDatabaseOperations(string $status, string $table, int|string $id, array $fieldArray, DataHandler $dataHandler): void
23+
{
24+
match ($status) {
25+
'new' => $this->new($table),
26+
'update' => $this->update($table, $fieldArray),
27+
default => null,
28+
};
29+
}
30+
31+
private function new(string $table): void
32+
{
33+
// TODO use \AUS\CacheAutomation\Service\AutoCacheTagService::isTableExcluded
34+
$this->flush($table . '--new');
35+
}
36+
37+
/**
38+
* @param array<string, mixed> $fieldArray
39+
*/
40+
private function update(string $table, array $fieldArray): void
41+
{
42+
// TODO use \AUS\CacheAutomation\Service\AutoCacheTagService::isTableExcluded maybe also isFieldExcluded?
43+
foreach (array_keys($fieldArray) as $field) {
44+
$this->flush($table . '-' . $field);
45+
}
46+
}
47+
48+
private function flush(string $tag): void
49+
{
50+
if (isset($this->alreadyFlushed[$tag])) {
51+
return;
52+
}
53+
54+
GeneralUtility::makeInstance(CacheManager::class)->flushCachesByTag($tag);
55+
$this->alreadyFlushed[$tag] = true;
56+
}
57+
}

Classes/Hooks/PageCache.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AUS\CacheAutomation\Hooks;
6+
7+
use AUS\CacheAutomation\Service\AutoCacheTagService;
8+
9+
final class PageCache
10+
{
11+
/**
12+
* needs replacement with AfterCacheableContentIsGeneratedEvent for TYPO3 v12
13+
*/
14+
public function contentPostProc(): void
15+
{
16+
AutoCacheTagService::getSingleton()->trigger();
17+
}
18+
}

0 commit comments

Comments
 (0)