Skip to content
Merged
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
14 changes: 9 additions & 5 deletions .github/workflows/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '8.1', '8.2', '8.3' ]
typo3: [ '11', '12' ]
php: [ '8.1', '8.2', '8.3', '8.4' ]
typo3: [ '11', '12', '13' ]
exclude:
- php: '8.1'
typo3: '13'
- php: '8.4'
typo3: '11'
steps:
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v5
- uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
Expand All @@ -26,4 +31,3 @@ jobs:
- run: composer require typo3/minimal="^${{ matrix.typo3 }}" --dev
- run: composer install --no-interaction --no-progress
- run: ./vendor/bin/grumphp run --ansi

9 changes: 5 additions & 4 deletions Classes/Middleware/MinifyMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Http\Stream;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class MinifyMiddleware implements MiddlewareInterface
{
public function __construct(private readonly MinifyService $minifyService)
{
}

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
// minimize only html
Expand All @@ -30,9 +33,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$body->rewind();
$html = $body->getContents();

$minifyService = GeneralUtility::makeInstance(MinifyService::class);
assert($minifyService instanceof MinifyService);
$html = $minifyService->minify($html);
$html = $this->minifyService->minify($html);
$body = new Stream('php://temp', 'wb+');
$body->write($html);
$response = $response->withBody($body);
Expand Down
4 changes: 3 additions & 1 deletion Classes/Service/MinifyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

namespace Pluswerk\PlusMinify\Service;

use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
use voku\helper\HtmlMin;

#[Autoconfigure(public: true)]
class MinifyService
{
public function minify(string $html): string
Expand Down Expand Up @@ -39,7 +41,7 @@ public function minify(string $html): string
$output = [];
$languageMeta = preg_match_all('#<meta charset=[a-zA-Z0-9-_"]*>#', $html, $output);
if ($languageMeta) {
$insertAt = strpos($html, (string)$output[0][0]) + strlen($output[0][0]);
$insertAt = strpos($html, $output[0][0]) + strlen($output[0][0]);
$html = substr($html, 0, $insertAt) . $typo3Comment . substr($html, $insertAt);
} else {
$html = $htmlMin->minify($html);
Expand Down
4 changes: 0 additions & 4 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ services:
autoconfigure: true
public: false

Pluswerk\PlusMinify\Service\:
resource: '../Classes/Service/*'
public: true

Pluswerk\PlusMinify\EventListener\RenderedEventListener:
tags:
- name: event.listener
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
"source": "https://github.com/pluswerk/minify"
},
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"composer-runtime-api": "^2",
"typo3/cms-core": "^11.5 || ^12.4",
"voku/html-min": "^4.5"
"typo3/cms-core": "^11.5 || ^12.4 || ^13.4",
"voku/html-min": "^4.5.1"
},
"require-dev": {
"andersundsehr/ssi-include": "^1.1.0",
"pluswerk/grumphp-config": "^7",
"saschaegerer/phpstan-typo3": "^1.10.0",
"ssch/typo3-rector": "^2.5.0"
"andersundsehr/ssi-include": "^1.1.0 || ^2.2.0",
"pluswerk/grumphp-config": "^7 || ^10",
"saschaegerer/phpstan-typo3": "^1.10.0 || ^2.1.1",
"ssch/typo3-rector": "^2.5.0 || ^3.6.2"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'version' => InstalledVersions::getPrettyVersion('pluswerk/minify'),
'constraints' => [
'depends' => [
'typo3' => '11.5.0 - 12.99.99',
'typo3' => '11.5.0 - 13.99.99',
],
'conflicts' => [],
'suggests' => [],
Expand Down
5 changes: 3 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
$rectorConfig->cacheDirectory('./var/cache/rector');

$rectorConfig->paths(
array_filter(explode("\n", (string)shell_exec("git ls-files | xargs ls -d 2>/dev/null | grep '\.php$'")))
array_filter(explode("\n", (string)shell_exec("git ls-files | xargs ls -d 2>/dev/null | grep -E '\.(php)$'")))
);

// define sets of rules
$rectorConfig->sets(
[
...RectorSettings::sets(true),
...RectorSettings::setsTypo3(true),
...RectorSettings::setsTypo3(false),
]
);

Expand All @@ -31,6 +31,7 @@
[
...RectorSettings::skip(),
...RectorSettings::skipTypo3(),

/**
* rector should not touch these files
*/
Expand Down