CsrfTransformer
in package
implements
IFormTransformer
FinalYes
Table of Contents
Interfaces
- IFormTransformer
- Transforms the data submitted with a POST request from its PHP representation (parsedBody) to its representation in the app (formData).
Constants
- CSRF_FORM_ELEMENT_NAME : mixed = '_csrf'
Properties
Methods
- __construct() : mixed
- transformSubmittedData() : mixed
- Extract the submitted value for the given field and convert it to the app data format.
Constants
CSRF_FORM_ELEMENT_NAME
public
mixed
CSRF_FORM_ELEMENT_NAME
= '_csrf'
Properties
$session
private
SessionManager
$session
Methods
__construct()
public
__construct(SessionManager $session) : mixed
Parameters
- $session : SessionManager
transformSubmittedData()
Extract the submitted value for the given field and convert it to the app data format.
public
transformSubmittedData(array<string|int, mixed> $parsedPayload, array<string|int, mixed> $uploadedFiles) : mixed
It is not always possible to decide whether a value evaluating to null or false was submitted or if no value was submitted because of a malformed or non-valid request for instance. For instance unchecked checkboxes submit the same value (actually, no submitted value at all, not even null), than if the field did not exist in the HTML form at all. A string left blank will evaluate to an empty string and not to null.
Parameters
- $parsedPayload : array<string|int, mixed>
- $uploadedFiles : array<string|int, mixed>
Attributes
- #[Override]
Return values
mixed —The submitted value converted to the app data format, or null if the user submitted a value evaluating to null.