Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce eventlistener that minifies ssi_include html parts #11

Merged
merged 2 commits into from
Jul 10, 2023
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
23 changes: 23 additions & 0 deletions Classes/EventListener/RenderedEventListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Pluswerk\PlusMinify\EventListener;

use AUS\SsiInclude\Event\RenderedEvent;
use Pluswerk\PlusMinify\Service\MinifyService;

class RenderedEventListener
{
protected MinifyService $minifyService;

public function __construct(MinifyService $minifyService)
{
$this->minifyService = $minifyService;
}

public function __invoke(RenderedEvent $event): void
{
$html = $event->getHtml();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in require-dev we could install ssi_include to avoid these phpstan errors.

$html = $this->minifyService->minify($html);
$event->setHtml($html);
}
}
6 changes: 6 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ services:
Pluswerk\PlusMinify\Service\:
resource: '../Classes/Service/*'
public: true

Pluswerk\PlusMinify\EventListener\RenderedEventListener:
tags:
- name: event.listener
identifier: 'Pluswerk\PlusMinify\EventListener\RenderedEventListener'
event: AUS\SsiInclude\Event\RenderedEvent
48 changes: 25 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
{
"name" : "pluswerk/minify",
"type" : "typo3-cms-extension",
"description" : "Pluswerk: Minify - Minifies your html",
"homepage" : "https://www.pluswerk.ag",
"license" : "GPL-2.0-or-later",
"support" : {
"source" : "https://github.com/pluswerk/minify"
"name": "pluswerk/minify",
"description": "Pluswerk: Minify - Minifies your html",
"license": "GPL-2.0-or-later",
"type": "typo3-cms-extension",
"homepage": "https://www.pluswerk.ag",
"support": {
"source": "https://github.com/pluswerk/minify"
},
"autoload" : {
"psr-4" : {
"Pluswerk\\PlusMinify\\" : "Classes/"
"require": {
"php": "^8.0",
"composer-runtime-api": "^2",
"typo3/cms-core": "^11.5 || ^12.4",
"voku/html-min": "^4.5"
},
"require-dev": {
"andersundsehr/ssi-include": "dev-main",
"pluswerk/grumphp-config": "^6",
"saschaegerer/phpstan-typo3": "^1.8.2",
"ssch/typo3-rector": "^1.1.3"
},
"autoload": {
"psr-4": {
"Pluswerk\\PlusMinify\\": "Classes/"
}
},
"config": {
Expand All @@ -18,24 +30,14 @@
"typo3/class-alias-loader": true,
"phpro/grumphp": true,
"pluswerk/grumphp-config": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"ergebnis/composer-normalize": true
},
"sort-packages": true
},
"extra" : {
"extra": {
"typo3/cms": {
"extension-key": "minify"
}
},
"require" : {
"php": "~8.0 || ~8.1 || ~8.2",
"composer-runtime-api": "^2",
"typo3/cms-core": "^11.5 || ^12.4",
"voku/html-min": "^4.5"
},
"require-dev": {
"pluswerk/grumphp-config": "^6",
"saschaegerer/phpstan-typo3": "^1.8.2",
"ssch/typo3-rector": "^1.1.3"
}
}