ModuleData
New in version 12.0
The module
backend request attribute is available when a backend
module is requested. It holds the object \TYPO3\
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.
Note
It is still possible to store and retrieve arbitrary module data. The
definition of module
in the module registration only defines, which
properties can be overwritten in a request (with GET/POST).
To restrict the values of module data properties, the given Module
object can be cleaned, for example, in a controller:
$allowedValues = ['foo', 'bar'];
$this->moduleData->clean('property', $allowedValues);
If Module
contains property
, the value is checked against the
$allowed
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\ Module Data
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
- get ( string $propertyName, ?mixed $default = NULL)
-
- param $propertyName
-
the propertyName
- param $default
-
the default, default: NULL
- Returns
-
?mixed
- 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