@@ -17,43 +17,43 @@ |
||
17 | 17 | */ |
18 | 18 | class CleanHtmlMiddleware implements MiddlewareInterface |
19 | 19 | { |
20 | - /** |
|
21 | - * @var CleanHtmlService |
|
22 | - */ |
|
23 | - protected $cleanHtmlService = null; |
|
24 | - |
|
25 | - public function __construct() |
|
26 | - { |
|
27 | - $this->cleanHtmlService = GeneralUtility::makeInstance(CleanHtmlService::class); |
|
28 | - } |
|
29 | - |
|
30 | - /** |
|
31 | - * Clean the HTML output |
|
32 | - * |
|
33 | - * @param ServerRequestInterface $request |
|
34 | - * @param RequestHandlerInterface $handler |
|
35 | - * @return ResponseInterface |
|
36 | - */ |
|
37 | - public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
38 | - { |
|
39 | - $response = $handler->handle($request); |
|
40 | - |
|
41 | - if ( |
|
42 | - !($response instanceof NullResponse) |
|
43 | - && $GLOBALS['TSFE'] instanceof TypoScriptFrontendController |
|
44 | - ) { |
|
45 | - |
|
46 | - $processedHtml = $this->cleanHtmlService->clean( |
|
47 | - $response->getBody()->__toString(), |
|
48 | - $GLOBALS['TSFE']->config['config']['sourceopt.'] |
|
49 | - ); |
|
50 | - |
|
51 | - // Replace old body with $processedHtml |
|
52 | - $responseBody = new Stream('php://temp', 'rw'); |
|
53 | - $responseBody->write($processedHtml); |
|
54 | - $response = $response->withBody($responseBody); |
|
55 | - } |
|
56 | - |
|
57 | - return $response; |
|
58 | - } |
|
20 | + /** |
|
21 | + * @var CleanHtmlService |
|
22 | + */ |
|
23 | + protected $cleanHtmlService = null; |
|
24 | + |
|
25 | + public function __construct() |
|
26 | + { |
|
27 | + $this->cleanHtmlService = GeneralUtility::makeInstance(CleanHtmlService::class); |
|
28 | + } |
|
29 | + |
|
30 | + /** |
|
31 | + * Clean the HTML output |
|
32 | + * |
|
33 | + * @param ServerRequestInterface $request |
|
34 | + * @param RequestHandlerInterface $handler |
|
35 | + * @return ResponseInterface |
|
36 | + */ |
|
37 | + public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
38 | + { |
|
39 | + $response = $handler->handle($request); |
|
40 | + |
|
41 | + if ( |
|
42 | + !($response instanceof NullResponse) |
|
43 | + && $GLOBALS['TSFE'] instanceof TypoScriptFrontendController |
|
44 | + ) { |
|
45 | + |
|
46 | + $processedHtml = $this->cleanHtmlService->clean( |
|
47 | + $response->getBody()->__toString(), |
|
48 | + $GLOBALS['TSFE']->config['config']['sourceopt.'] |
|
49 | + ); |
|
50 | + |
|
51 | + // Replace old body with $processedHtml |
|
52 | + $responseBody = new Stream('php://temp', 'rw'); |
|
53 | + $responseBody->write($processedHtml); |
|
54 | + $response = $response->withBody($responseBody); |
|
55 | + } |
|
56 | + |
|
57 | + return $response; |
|
58 | + } |
|
59 | 59 | } |