Completed
Pull Request — master (#126)
by
unknown
14:38
created
Classes/Service/RegExRepService.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -11,31 +11,31 @@
 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 => &$content) {
20
-                if (isset($config[$section][$key.'.'])) {
21
-                    $content = $GLOBALS['TSFE']->cObj
22
-                        ->stdWrap(
23
-                            $content,
24
-                            $config[$section][$key.'.']
25
-                        )
26
-                    ;
27
-                    unset($config[$section][$key.'.']); // keep!
28
-                }
29
-            }
30
-            ksort($config[$section]); // only for safety
31
-        }
18
+		foreach ($config as $section => &$block) {
19
+			foreach ($block as $key => &$content) {
20
+				if (isset($config[$section][$key.'.'])) {
21
+					$content = $GLOBALS['TSFE']->cObj
22
+						->stdWrap(
23
+							$content,
24
+							$config[$section][$key.'.']
25
+						)
26
+					;
27
+					unset($config[$section][$key.'.']); // keep!
28
+				}
29
+			}
30
+			ksort($config[$section]); // only for safety
31
+		}
32 32
 
33
-        $arrIntersectKeysCnt = 2 * \count(array_intersect_key($config['search.'], $config['replace.']));
33
+		$arrIntersectKeysCnt = 2 * \count(array_intersect_key($config['search.'], $config['replace.']));
34 34
 
35
-        if ((bool) (\count($config['search.']) + \count($config['replace.']) - $arrIntersectKeysCnt)) {
36
-            throw new \Exception('search/replace requests have diverged');
37
-        }
35
+		if ((bool) (\count($config['search.']) + \count($config['replace.']) - $arrIntersectKeysCnt)) {
36
+			throw new \Exception('search/replace requests have diverged');
37
+		}
38 38
 
39
-        return preg_replace($config['search.'], $config['replace.'], $html);
40
-    }
39
+		return preg_replace($config['search.'], $config['replace.'], $html);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
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.