EXTBASEPLUGIN

New in version 12.3

The content object EXTBASEPLUGIN allows to render Extbase plugins.

Properties

cache

cache
Type
cache

See cache function description for details.

extensionName

extensionName
Type
string

pluginName

pluginName
Type
string

The plugin name.

Example: Display an Extbase plugin via TypoScript

EXT:my_extension/Configuration/TypoScript/setup.typoscript
page.10 = EXTBASEPLUGIN
page.10.extensionName = MyExtension
page.10.pluginName = MyPlugin
Copied!

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>:

EXT:my_extension/Resources/Private/Templates/Pages/SomeTemplate.html
<!-- ... -->
<f:cObject
        typoscriptObjectPath="lib.myPlugin"
        data="{someValue: page.pageRecord.someValue, someSetting: site.someSetting}"
/>
Copied!

Create a lib object which utilizes the EXTBASEPLUGIN into a lib object:

EXT:my_extension/Configuration/TypoScript/setup.typoscript
lib.myPlugin = EXTBASEPLUGIN
lib.myPlugin {
    extensionName = MyExtension
    pluginName = MyPlugIn1
    settings.detailPid = 42
}
Copied!

For extensionName and pluginName use the names as configured in \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin():

EXT:my_extension/ext_localconf.php
<?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,
);
Copied!

If you passed data to the ViewHelper, you can access the data in the controller's action by getting the currentContentObject from the request:

EXT:my_extension/Classes/Controller/MyController.php
<?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();
    }
}
Copied!

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
}
Copied!

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.