Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Introduce cObject for Extbase plugins
A new TypoScript cObject "EXTBASEPLUGIN" is added for Extbase plugins to allow Extbase authors to not reference the Extbase Bootstrap class anymore. This way, newcomers do not have to worry about running defining USER/USER_INT things, which is not relevant for them. As most existing users use the API, it does not matter much, except for places. In the future, Extbase logic can / should be moved to the Extbase Plugin Content Object, while removing the dependency on the ConfigurationManager and the cacheable actions from the Bootstrap and RequestBuilder classes. At the current point, this is very much convenience and helps to further document to distinguish between Plugins (= PHP code) and regular Content Types. Resolves: #100293 Releases: main Change-Id: Ia3a7cceddd9f93dc606c3194828d26bed5a8f2b2 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76517 Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de> Reviewed-by: Jochen <rothjochen@gmail.com> Tested-by: Jochen <rothjochen@gmail.com> Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de> Tested-by: core-ci <typo3@b13.com> Tested-by: Georg Ringer <georg.ringer@gmail.com> Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
- Loading branch information
1 parent
a4fb013
commit f7df5aa
Showing
7 changed files
with
144 additions
and
12 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...ion/Changelog/12.3/Feature-100293-NewContentObjectEXTBASEPLUGINInTypoScript.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
.. include:: /Includes.rst.txt | ||
|
||
.. _feature-100293-1679673289: | ||
|
||
================================================================ | ||
Feature: #100293 - New ContentObject EXTBASEPLUGIN in TypoScript | ||
================================================================ | ||
|
||
See :issue:`100293` | ||
|
||
Description | ||
=========== | ||
|
||
In order to lower the barrier for newcomers in the TYPO3 world, TYPO3 now has | ||
a custom ContentObject in TypoScript called :typoscript:`EXTBASEPLUGIN`. | ||
|
||
Previously, TypoScript code for Extbase plugins looked like this: | ||
|
||
.. code-block:: typoscript | ||
page.10 = USER | ||
page.10 { | ||
userFunc = TYPO3\\CMS\\Extbase\\Core\\Bootstrap->run | ||
extensionName = shop | ||
pluginName = cart | ||
} | ||
The new way, which Extbase Plugin Registration uses under the hood now, looks | ||
like this: | ||
|
||
.. code-block:: typoscript | ||
page.10 = EXTBASEPLUGIN | ||
page.10.extensionName = shop | ||
page.10.pluginName = cart | ||
The old way still works, but it is recommended to use the :typoscript:`EXTBASEPLUGIN` | ||
ContentObject, as the direct reference to a PHP class (Bootstrap) might be | ||
optimized in future versions. | ||
|
||
|
||
Impact | ||
====== | ||
|
||
This change is an effort to distinguish between plugins and regular other | ||
more static content. | ||
|
||
Extbase is the de-facto standard for Plugins, which serve dynamic content by | ||
custom PHP code divided in controllers and actions by extension developers. | ||
|
||
Regular other content can be written in pure TypoScript, such as ContentObjects | ||
like FLUIDTEMPLATE, HMENU, COA or TEXT is used for other kind of renderings | ||
in the frontend. | ||
|
||
.. index:: TypoScript, ext:extbase |
65 changes: 65 additions & 0 deletions
65
typo3/sysext/extbase/Classes/ContentObject/ExtbasePluginContentObject.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace TYPO3\CMS\Extbase\ContentObject; | ||
|
||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Extbase\Core\Bootstrap; | ||
use TYPO3\CMS\Frontend\ContentObject\AbstractContentObject; | ||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; | ||
|
||
/** | ||
* Contains EXTBASEPLUGIN class object. | ||
* | ||
* Creates a request and dispatches it to the controller which was specified | ||
* by TS Setup and returns the content, currently handed over to the | ||
* Extbase Bootstrap. | ||
* | ||
* This class is the main entry point for extbase extensions in the TYPO3 Frontend. | ||
*/ | ||
class ExtbasePluginContentObject extends AbstractContentObject | ||
{ | ||
public function render($conf = []) | ||
{ | ||
$extbaseBootstrap = GeneralUtility::makeInstance(Bootstrap::class); | ||
$extbaseBootstrap->setContentObjectRenderer($this->getContentObjectRenderer()); | ||
if ($this->cObj->getUserObjectType() === false) { | ||
// Come here only if we are not called from $TSFE->processNonCacheableContentPartsAndSubstituteContentMarkers()! | ||
$this->cObj->setUserObjectType(ContentObjectRenderer::OBJECTTYPE_USER); | ||
} | ||
$extbaseBootstrap->initialize($conf); | ||
$content = $extbaseBootstrap->handleFrontendRequest($this->request); | ||
// Rendering is deferred, as the action should not be cached, we pump this now to TSFE to be executed later-on | ||
if ($this->cObj->doConvertToUserIntObject) { | ||
$this->cObj->doConvertToUserIntObject = false; | ||
// @todo: this should be removed in the future in TSFE to allow more "uncacheables" than USER_INTs | ||
// also, the handleFrontendRequest() should return the full response in the future | ||
$conf['userFunc'] = Bootstrap::class . '->run'; | ||
$this->cObj->setUserObjectType(ContentObjectRenderer::OBJECTTYPE_USER_INT); | ||
$tsfe = $this->getTypoScriptFrontendController(); | ||
$substKey = 'INT_SCRIPT.' . $tsfe->uniqueHash(); | ||
$content = '<!--' . $substKey . '-->'; | ||
$tsfe->config['INTincScript'][$substKey] = [ | ||
'conf' => $conf, | ||
'cObj' => serialize($this->cObj), | ||
'type' => 'FUNC', | ||
]; | ||
} | ||
$this->cObj->setUserObjectType(false); | ||
return $content; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters