EXTBASEPLUGIN
New in version 12.3
The content object EXTBASEPLUGIN
allows to render
Extbase plugins.
Properties
cache
-
- Type
- cache
See cache function description for details.
extensionName
-
- Type
- string
The extension name.
pluginName
-
- Type
- string
The plugin name.
Example: Display an Extbase plugin via TypoScript
page.10 = EXTBASEPLUGIN
page.10.extensionName = MyExtension
page.10.pluginName = MyPlugin
Example: Display an Extbase plugin in a Fluid template
It is possible to display an Extbase plugin in Fluid using the CObject ViewHelper <f:cObject>:
<!-- ... -->
<f:cObject
typoscriptObjectPath="lib.myPlugin"
data="{someValue: page.pageRecord.someValue, someSetting: site.someSetting}"
/>
Create a lib object which utilizes the EXTBASEPLUGIN
into
a lib
object:
lib.myPlugin = EXTBASEPLUGIN
lib.myPlugin {
extensionName = MyExtension
pluginName = MyPlugIn1
settings.detailPid = 42
}
For extension
and plugin
use the names as configured in
\TYPO3\
:
<?php
use MyVendor\MyExtension\Controller\MyController;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
defined('TYPO3') || die('Access denied.');
ExtensionUtility::configurePlugin(
'MyExtension',
'MyPlugIn1',
[MyController::class => 'list, show'],
[],
ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT,
);
If you passed data to the ViewHelper, you can access the data in the controller's action by getting the currentContentObject from the request:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Controller;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
class MyController extends ActionController
{
public function listAction(): ResponseInterface
{
/** @var ContentObjectRenderer $contentObject */
$contentObject = $this->request->getAttribute('currentContentObject');
$dataFromTypoScript = $contentObject->data;
$someValue = (int)($dataFromTypoScript['someValue'] ?? 0);
$someSetting = $dataFromTypoScript['someSetting'] ?? '';
// Do something
return $this->htmlResponse();
}
}
Note
You should treat all data from the
Content
as
potential user input. Do not use it unescaped and do not trust to receive
certain types.
History
The EXTBASEPLUGIN
allows Extbase authors to not reference the
Extbase Bootstrap class anymore, like for previous TYPO3 versions below version
12.
Previously, TypoScript code for Extbase plugins looked like this:
page.10 = USER
page.10 {
userFunc = TYPO3\\CMS\\Extbase\\Core\\Bootstrap->run
extensionName = MyExtension
pluginName = MyPlugin
}
This way still works, but it is recommended to use the
EXTBASEPLUGIN
content object, as the direct reference to a PHP
class (Bootstrap) might be optimized in future versions.
For extension that need to remain compatible with TYPO3 v11 and v12, the Bootstrap way should be used.