Feature #82809

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin should return the registered type

Added by Benjamin Serfhos over 1 year ago. Updated over 1 year ago.

Status:
New
Priority:
Could have
Assignee:
-
Category:
Backend API
Target version:
-
Start date:
2017-10-19
Due date:
% Done:

0%

Estimated time:
0.10 h
PHP Version:
Tags:
Complexity:
no-brainer
Sprint Focus:

Description

All extensions uses this function and for adding flexform or other extra configuration they 'hardcode' their typename.
To add flexibility the used typename could be returned in the function.

So for example the following is used to register an plugin.

// This creates the myext_display variable available in the core
ExtensionUtility::registerPlugin(
    'my_ext',
    'Display',
    'LLL:EXT:my_ext/Resources/Private/Language/locallang_be.xlf:publications.list.title'
);

// Setup flex form
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['myext_display'] = 'layout, select_key';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['myext_display'] = 'pi_flexform';
ExtensionManagementUtility::addPiFlexFormValue(
    'myext_display',
    'FILE:EXT:my_ext/Configuration/FlexForm/List.xml'
);

While the following would be slightly better and flexible.

$type = ExtensionUtility::registerPlugin(
    'my_ext',
    'Display',
    'LLL:EXT:my_ext/Resources/Private/Language/locallang_be.xlf:publications.list.title'
);

if (!empty($type)) {
    // Setup flex form
    $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$type] = 'layout, select_key';
    $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$type] = 'pi_flexform';
    ExtensionManagementUtility::addPiFlexFormValue(
        $type,
        'FILE:EXT:my_ext/Configuration/FlexForm/List.xml'
    );
}

History

#1 Updated by Markus Sommer over 1 year ago

you can use $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['my_ext']['plugins']['Display']['pluginType'] to get the type :)

#2 Updated by Benjamin Serfhos over 1 year ago

Markus Sommer wrote:

you can use $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['my_ext']['plugins']['Display']['pluginType'] to get the type :)

I quote from implementation;

Configuration of controllers and actions is now stored in a global registry ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']). But you should never access this directly.

I think my suggestion would be more failproof :x

Also available in: Atom PDF