\Cake\HttpRequestTransformer

Translate and transform from PSR7 requests into CakePHP requests.

This is an important step for maintaining backwards compatibility with existing CakePHP applications, which depend on the CakePHP request object.

There is no reverse transform as the 'application' cannot return a mutated request object.

Summary

Methods
Properties
Constants
toCake()
No public properties found
No constants found
getParams()
getFiles()
convertFiles()
convertFile()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getParams()

getParams(\Psr\Http\Message\ServerRequestInterface  $request) : array

Extract the routing parameters out of the request object.

Parameters

\Psr\Http\Message\ServerRequestInterface $request

The request to extract params from.

Returns

array —

The routing parameters.

getFiles()

getFiles(\Psr\Http\Message\ServerRequestInterface  $request) : array

Extract the uploaded files out of the request object.

CakePHP expects to get arrays of file information and not the parsed objects that PSR7 requests contain. Downsample the data here.

Parameters

\Psr\Http\Message\ServerRequestInterface $request

The request to extract files from.

Returns

array —

The routing parameters.

convertFiles()

convertFiles(array  $data, array  $files, string  $path = '') : array

Convert a nested array of files to arrays.

Parameters

array $data

The data to add files to.

array $files

The file objects to convert.

string $path

The current array path.

Returns

array —

Converted file data

convertFile()

convertFile(\Psr\Http\Message\UploadedFileInterface  $file) : array

Convert a single file back into an array.

Parameters

\Psr\Http\Message\UploadedFileInterface $file

The file to convert.

Returns

array