[TASK] Deprecate PageGenerator::renderContent 80/57880/3
authorBenni Mack <benni@typo3.org>
Sun, 12 Aug 2018 11:18:51 +0000 (13:18 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Sun, 12 Aug 2018 17:11:22 +0000 (19:11 +0200)
The PSR-15 RequestHandler should be responsible for compiling content, avoiding
a call to a static method which uses global objects again, which are available
already in the RequestHandler.

Therefore this logic is moved into RequestHandler.

Resolves: #85822
Releases: master
Change-Id: Id37887152a11739b9a43abaa577695daa1957905
Reviewed-on: https://review.typo3.org/57880
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/core/Documentation/Changelog/master/Deprecation-85822-DeprecatePageGeneratorrenderContent.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/Http/RequestHandler.php
typo3/sysext/frontend/Classes/Page/PageGenerator.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85822-DeprecatePageGeneratorrenderContent.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85822-DeprecatePageGeneratorrenderContent.rst
new file mode 100644 (file)
index 0000000..da21706
--- /dev/null
@@ -0,0 +1,36 @@
+.. include:: ../../Includes.txt
+
+============================================================
+Deprecation: #85822 - Deprecate PageGenerator::renderContent
+============================================================
+
+See :issue:`85822`
+
+Description
+===========
+
+The PSR-15 RequestHandler should be responsible for compiling content, avoiding
+a call to a static method which uses global objects again, which are available
+already in the RequestHandler.
+
+Therefore this logic is moved into RequestHandler and :php:`PageGenerator::renderContent` is marked as deprecated.
+
+
+Impact
+======
+
+Calling the :php:`PageGenerator::renderContent` method will trigger a deprecation message.
+
+
+Affected Installations
+======================
+
+Any TYPO3 installation with a custom extension calling the static method above.
+
+
+Migration
+=========
+
+Move the render logic to your own extension.
+
+.. index:: Frontend, FullyScanned, ext:frontend
\ No newline at end of file
index 0ad5a80..0e460a3 100644 (file)
@@ -73,8 +73,24 @@ class RequestHandler implements RequestHandlerInterface, PsrRequestHandlerInterf
             $this->timeTracker->push('Page generation');
             $controller->generatePage_preProcessing();
             $controller->preparePageContentGeneration();
+
             // Content generation
-            PageGenerator::renderContent();
+            $this->timeTracker->incStackPointer();
+            $this->timeTracker->push($controller->sPre, 'PAGE');
+
+            $pageContent = $this->generatePageContent($controller);
+            // Now render the Page header (<head> tag content and wrap around <body> tag) - this is done
+            // after the "main" page Content, since some JS may be inserted at that point.
+            // if 'disableAllHeaderCode' is set, all the header-code is discarded
+            if ($controller->config['config']['disableAllHeaderCode']) {
+                $controller->content = $pageContent;
+            } else {
+                PageGenerator::renderContentWithHeader($pageContent);
+            }
+
+            $this->timeTracker->pull($this->timeTracker->LR ? $controller->content : '');
+            $this->timeTracker->decStackPointer();
+
             $controller->setAbsRefPrefix();
             $controller->generatePage_postProcessing();
             $this->timeTracker->pull();
@@ -132,6 +148,24 @@ class RequestHandler implements RequestHandlerInterface, PsrRequestHandlerInterf
     }
 
     /**
+     * Generates the main content part within <body> tags (except JS files/CSS files).
+     *
+     * @param TypoScriptFrontendController $controller
+     * @return string
+     */
+    protected function generatePageContent(TypoScriptFrontendController $controller): string
+    {
+        $pageContent = $controller->cObj->cObjGet($controller->pSetup);
+        if ($controller->pSetup['wrap']) {
+            $pageContent = $controller->cObj->wrap($pageContent, $controller->pSetup['wrap']);
+        }
+        if ($controller->pSetup['stdWrap.']) {
+            $pageContent = $controller->cObj->stdWrap($pageContent, $controller->pSetup['stdWrap.']);
+        }
+        return $pageContent;
+    }
+
+    /**
      * This request handler can handle any frontend request.
      *
      * @param ServerRequestInterface $request
index 7efb062..ac802fd 100644 (file)
@@ -44,9 +44,11 @@ class PageGenerator
 
     /**
      * Rendering the page content
+     * @deprecated since TYPO3 v9.4 will be removed in TYPO3 v10.0. This functionality is now within RequestHandler.
      */
     public static function renderContent()
     {
+        trigger_error('PageGenerator::renderContent() will be removed in TYPO3 v10.0. This logic is now built in TYPO3s Frontend RequestHandler.', E_USER_DEPRECATED);
         /** @var TypoScriptFrontendController $tsfe */
         $tsfe = $GLOBALS['TSFE'];
 
index c69ddac..e3336c2 100644 (file)
@@ -715,4 +715,11 @@ return [
             'Deprecation-85821-DeprecatedBoostrapMethods.rst',
         ],
     ],
+    'TYPO3\CMS\Frontend\Page\PageGenerator::renderContent' => [
+        'numberOfMandatoryArguments' => 0,
+        'maximumNumberOfArguments' => 0,
+        'restFiles' => [
+            'Deprecation-85822-DeprecatePageGeneratorrenderContent.rst',
+        ],
+    ],
 ];