ModuleData

New in version 12.0

The moduleData backend request attribute is available when a backend module is requested. It holds the object \TYPO3\CMS\Backend\Module\ModuleData which contains the stored module data that might have been overwritten through the current request (with GET/POST).

Through the module registration one can define, which properties can be overwritten via GET/POST and their default value.

The whole determination is done before the requested route target - usually a backend controller - is called. This means, the route target can just read the final module data.

To restrict the values of module data properties, the given ModuleData object can be cleaned, for example, in a controller:

$allowedValues = ['foo', 'bar'];
$this->moduleData->clean('property', $allowedValues);
Copied!

If ModuleData contains property, the value is checked against the $allowedValues list. If the current value is valid, nothing happens. Otherwise the value is either changed to the default or if this value is also not allowed, to the first allowed value.

API

class ModuleData
Fully qualified name
\TYPO3\CMS\Backend\Module\ModuleData

A simple DTO containing the user specific module settings, e.g. whether the clipboard is shown.

The DTO is created in the PSR-15 middleware BackendModuleValidator, in case a backend module is requested and the user has necessary access permissions. The created DTO is then added as attribute to the PSR-7 Request and can be further used in components, such as middlewares or the route target (usually a backend controller).

createFromModule ( \TYPO3\CMS\Backend\Module\ModuleInterface $module, array $data)
param $module

the module

param $data

the data

Returns
self
getModuleIdentifier ( )
Returns
string
get ( string $propertyName, ?mixed $default = NULL)
param $propertyName

the propertyName

param $default

the default, default: NULL

Returns
?mixed
has ( string $propertyName)
param $propertyName

the propertyName

Returns
bool
set ( string $propertyName, ?mixed $value)
param $propertyName

the propertyName

param $value

the value

clean ( string $propertyName, array $allowedValues)

Cleans a single property by the given allowed list. First fallback is the default data list. If this list does also not contain an allowed value, the first value from the allowed list is taken.

param $propertyName

the propertyName

param $allowedValues

the allowedValues

Return description

True if something has been cleaned up

Returns
bool
cleanUp ( array $allowedData, bool $useKeys = true)

Cleans up all module data, which are defined in the given allowed data list. Usually called with $MOD_MENU.

param $allowedData

the allowedData

param $useKeys

the useKeys, default: true

Returns
bool
toArray ( )
Returns
array