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 1 commit
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