UserFrosting API

RequestDataTransformer implements RequestDataTransformerInterface

RequestDataTransformer Class.

Perform a series of transformations on a set of data fields, as specified by a RequestSchemaInterface.

Tags
author

Alex Weissman (https://alexanderweissman.com)

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

Methods

transform()

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
mixed

purgeHtmlCharacters()

Autodetect if a field is an array or scalar, and filter appropriately.

protected purgeHtmlCharacters( $value : mixed ) : mixed
Parameters
$value : mixed
Return values
mixed

trim()

Autodetect if a field is an array or scalar, and filter appropriately.

protected trim( $value : mixed ) : mixed
Parameters
$value : mixed
Return values
mixed

Search results