RequestDataTransformer implements RequestDataTransformerInterface
RequestDataTransformer Class.
Perform a series of transformations on a set of data fields, as specified by a RequestSchemaInterface.
Tags
Table of Contents
$schema | RequestSchemaInterface | |
---|---|---|
$purifier | HTMLPurifier | |
__construct() | Create a new data transformer. | mixed |
setSchema() | Set the schema for this transformer, as a valid RequestSchemaInterface object. | mixed |
transform() | Process each field in the specified data array, applying transformations in the specified order. | array |
transformField() | Transform a raw field value. | string |
escapeHtmlCharacters() | Autodetect if a field is an array or scalar, and filter appropriately. | mixed |
purgeHtmlCharacters() | Autodetect if a field is an array or scalar, and filter appropriately. | mixed |
trim() | Autodetect if a field is an array or scalar, and filter appropriately. | mixed |
Properties
$schema
protected
RequestSchemaInterface
$schema
$purifier
protected
HTMLPurifier
$purifier
Methods
__construct()
Create a new data transformer.
public
__construct(
$schema :
RequestSchemaInterface
)
: mixed
Parameters
- $schema : RequestSchemaInterface
A RequestSchemaInterface object, containing the transformation rules.
Return values
mixedsetSchema()
Set the schema for this transformer, as a valid RequestSchemaInterface object.
public
setSchema(
$schema :
RequestSchemaInterface
)
: mixed
Parameters
- $schema : RequestSchemaInterface
A RequestSchemaInterface object, containing the transformation rules.
Return values
mixedtransform()
Process each field in the specified data array, applying transformations in the specified order.
public
transform(
$data :
array
[, $onUnexpectedVar :
mixed
= 'skip' ]
)
: array
Example transformations: escape/purge/purify HTML entities Also, set any default values for unspecified fields.
Parameters
- $data : array
The array of data to be transformed.
- $onUnexpectedVar : mixed = 'skip'
Return values
array —The array of transformed data, mapping field names => values.
transformField()
Transform a raw field value.
public
transformField(
$name :
mixed
, $value :
mixed
)
: string
Parameters
- $name : mixed
The name of the field to transform, as specified in the schema.
- $value : mixed
The value to be transformed.
Return values
string —The transformed value.
escapeHtmlCharacters()
Autodetect if a field is an array or scalar, and filter appropriately.
protected
escapeHtmlCharacters(
$value :
mixed
)
: mixed
Parameters
- $value : mixed
Return values
mixedpurgeHtmlCharacters()
Autodetect if a field is an array or scalar, and filter appropriately.
protected
purgeHtmlCharacters(
$value :
mixed
)
: mixed
Parameters
- $value : mixed
Return values
mixedtrim()
Autodetect if a field is an array or scalar, and filter appropriately.
protected
trim(
$value :
mixed
)
: mixed
Parameters
- $value : mixed