Completed
Push — master ( d4425c...f6bd62 )
by Tim
18s queued 13s
created
Classes/Middleware/RegExRepMiddleware.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -19,30 +19,30 @@
 block discarded – undo
19 19
  */
20 20
 class RegExRepMiddleware implements MiddlewareInterface
21 21
 {
22
-    /**
23
-     * RegEx search & replace @ HTML output.
24
-     */
25
-    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
26
-    {
27
-        $response = $handler->handle($request);
22
+	/**
23
+	 * RegEx search & replace @ HTML output.
24
+	 */
25
+	public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
26
+	{
27
+		$response = $handler->handle($request);
28 28
 
29
-        if (!($response instanceof NullResponse)
30
-        && $GLOBALS['TSFE'] instanceof TypoScriptFrontendController
31
-        && $GLOBALS['TSFE']->cObj instanceof ContentObjectRenderer
32
-        && \is_array($GLOBALS['TSFE']->config['config']['replacer.']['search.'])
33
-        && \is_array($GLOBALS['TSFE']->config['config']['replacer.']['replace.'])
34
-        && 'text/html' == substr($response->getHeaderLine('Content-Type'), 0, 9)
35
-        && !empty($response->getBody())
36
-        ) {
37
-            $processedHtml = GeneralUtility::makeInstance(\HTML\Sourceopt\Service\RegExRepService::class)
38
-                ->process((string) $response->getBody())
39
-            ;
29
+		if (!($response instanceof NullResponse)
30
+		&& $GLOBALS['TSFE'] instanceof TypoScriptFrontendController
31
+		&& $GLOBALS['TSFE']->cObj instanceof ContentObjectRenderer
32
+		&& \is_array($GLOBALS['TSFE']->config['config']['replacer.']['search.'])
33
+		&& \is_array($GLOBALS['TSFE']->config['config']['replacer.']['replace.'])
34
+		&& 'text/html' == substr($response->getHeaderLine('Content-Type'), 0, 9)
35
+		&& !empty($response->getBody())
36
+		) {
37
+			$processedHtml = GeneralUtility::makeInstance(\HTML\Sourceopt\Service\RegExRepService::class)
38
+				->process((string) $response->getBody())
39
+			;
40 40
 
41
-            $responseBody = new Stream('php://temp', 'rw');
42
-            $responseBody->write($processedHtml);
43
-            $response = $response->withBody($responseBody);
44
-        }
41
+			$responseBody = new Stream('php://temp', 'rw');
42
+			$responseBody->write($processedHtml);
43
+			$response = $response->withBody($responseBody);
44
+		}
45 45
 
46
-        return $response;
47
-    }
46
+		return $response;
47
+	}
48 48
 }
Please login to merge, or discard this patch.
Classes/Middleware/CleanHtmlMiddleware.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,32 +18,32 @@
 block discarded – undo
18 18
  */
19 19
 class CleanHtmlMiddleware implements MiddlewareInterface
20 20
 {
21
-    /**
22
-     * Clean the HTML output.
23
-     */
24
-    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
25
-    {
26
-        $response = $handler->handle($request);
21
+	/**
22
+	 * Clean the HTML output.
23
+	 */
24
+	public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
25
+	{
26
+		$response = $handler->handle($request);
27 27
 
28
-        if (!($response instanceof NullResponse)
29
-        && $GLOBALS['TSFE'] instanceof TypoScriptFrontendController
30
-        && ($GLOBALS['TSFE']->config['config']['sourceopt.']['enabled'] ?? false)
31
-        && 'text/html' == substr($response->getHeaderLine('Content-Type'), 0, 9)
32
-        && !empty($response->getBody())
33
-        ) {
34
-            $processedHtml = GeneralUtility::makeInstance(\HTML\Sourceopt\Service\CleanHtmlService::class)
35
-                ->clean(
36
-                    (string) $response->getBody(),
37
-                    (array) $GLOBALS['TSFE']->config['config']['sourceopt.']
38
-                )
39
-            ;
28
+		if (!($response instanceof NullResponse)
29
+		&& $GLOBALS['TSFE'] instanceof TypoScriptFrontendController
30
+		&& ($GLOBALS['TSFE']->config['config']['sourceopt.']['enabled'] ?? false)
31
+		&& 'text/html' == substr($response->getHeaderLine('Content-Type'), 0, 9)
32
+		&& !empty($response->getBody())
33
+		) {
34
+			$processedHtml = GeneralUtility::makeInstance(\HTML\Sourceopt\Service\CleanHtmlService::class)
35
+				->clean(
36
+					(string) $response->getBody(),
37
+					(array) $GLOBALS['TSFE']->config['config']['sourceopt.']
38
+				)
39
+			;
40 40
 
41
-            // Replace old body with $processedHtml
42
-            $responseBody = new Stream('php://temp', 'rw');
43
-            $responseBody->write($processedHtml);
44
-            $response = $response->withBody($responseBody);
45
-        }
41
+			// Replace old body with $processedHtml
42
+			$responseBody = new Stream('php://temp', 'rw');
43
+			$responseBody->write($processedHtml);
44
+			$response = $response->withBody($responseBody);
45
+		}
46 46
 
47
-        return $response;
48
-    }
47
+		return $response;
48
+	}
49 49
 }
Please login to merge, or discard this patch.
Classes/Service/RegExRepService.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -11,34 +11,34 @@
 block discarded – undo
11 11
  */
12 12
 class RegExRepService implements \TYPO3\CMS\Core\SingletonInterface
13 13
 {
14
-    public function process(string $html): string
15
-    {
16
-        $config = $GLOBALS['TSFE']->config['config']['replacer.'];
14
+	public function process(string $html): string
15
+	{
16
+		$config = $GLOBALS['TSFE']->config['config']['replacer.'];
17 17
 
18
-        foreach ($config as $section => &$block) {
19
-            foreach ($block as $key => &$regex) {
20
-                if ('search.' == $section && '.' !== $key[-1] && !preg_match('/^(.).+\1[a-z]*$/i', $regex)) {
21
-                    throw new \Exception("Please check your RegEx @ {$key} = {$regex}");
22
-                }
23
-                if (isset($config[$section][$key.'.'])) {
24
-                    $regex = $GLOBALS['TSFE']->cObj
25
-                        ->stdWrap(
26
-                            $regex,
27
-                            $config[$section][$key.'.']
28
-                        )
29
-                    ;
30
-                    unset($config[$section][$key.'.']); // keep!
31
-                }
32
-            }
33
-            ksort($config[$section]); // only for safety
34
-        }
18
+		foreach ($config as $section => &$block) {
19
+			foreach ($block as $key => &$regex) {
20
+				if ('search.' == $section && '.' !== $key[-1] && !preg_match('/^(.).+\1[a-z]*$/i', $regex)) {
21
+					throw new \Exception("Please check your RegEx @ {$key} = {$regex}");
22
+				}
23
+				if (isset($config[$section][$key.'.'])) {
24
+					$regex = $GLOBALS['TSFE']->cObj
25
+						->stdWrap(
26
+							$regex,
27
+							$config[$section][$key.'.']
28
+						)
29
+					;
30
+					unset($config[$section][$key.'.']); // keep!
31
+				}
32
+			}
33
+			ksort($config[$section]); // only for safety
34
+		}
35 35
 
36
-        $arrIntersectKeysCnt = 2 * \count(array_intersect_key($config['search.'], $config['replace.']));
36
+		$arrIntersectKeysCnt = 2 * \count(array_intersect_key($config['search.'], $config['replace.']));
37 37
 
38
-        if ((bool) (\count($config['search.']) + \count($config['replace.']) - $arrIntersectKeysCnt)) {
39
-            throw new \Exception('search/replace requests have diverged');
40
-        }
38
+		if ((bool) (\count($config['search.']) + \count($config['replace.']) - $arrIntersectKeysCnt)) {
39
+			throw new \Exception('search/replace requests have diverged');
40
+		}
41 41
 
42
-        return preg_replace($config['search.'], $config['replace.'], $html);
43
-    }
42
+		return preg_replace($config['search.'], $config['replace.'], $html);
43
+	}
44 44
 }
Please login to merge, or discard this patch.