Deprecation: #111116 - BackendUtility::getModuleData() 

See forge#111116

Description 

The method \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData() has been deprecated. It managed module settings in the backend user configuration based on a $MOD_MENU array, a pattern from before backend modules were registered via Configuration/Backend/Modules.php.

Backend modules receive their settings as \TYPO3\CMS\Backend\Module\ModuleData object in the request attribute moduleData , which is created, filled and persisted by the backend module middleware.

Impact 

Calling the method triggers a PHP E_USER_DEPRECATED error. The extension scanner reports usages.

Affected installations 

Installations with extensions calling BackendUtility::getModuleData() in custom backend modules.

Migration 

Declare the module settings and their default values in the moduleData option of the module registration. Values sent with the request under the same names are then persisted automatically. Read the settings from the moduleData request attribute and use ModuleData->cleanUp() to restrict menu settings to allowed values.

Before:

use TYPO3\CMS\Backend\Utility\BackendUtility;

$menu = [
    'mode' => ['list' => 'List', 'tiles' => 'Tiles'],
];
$settings = BackendUtility::getModuleData(
    $menu,
    $request->getParsedBody()['SET'] ?? [],
    'my_module'
);
$mode = $settings['mode'];
Copied!

After:

EXT:my_extension/Configuration/Backend/Modules.php
return [
    'my_module' => [
        // ...
        'moduleData' => [
            'mode' => 'list',
        ],
    ],
];
Copied!
use TYPO3\CMS\Backend\Module\ModuleData;

/** @var ModuleData $moduleData */
$moduleData = $request->getAttribute('moduleData');
if ($moduleData->clean('mode', ['list', 'tiles'])) {
    $this->getBackendUser()->pushModuleData(
        $moduleData->getModuleIdentifier(),
        $moduleData->toArray()
    );
}
$mode = $moduleData->get('mode');
Copied!