Class RequestTransformer
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.
Method Summary
Method Detail
convertFile() protected static
convertFile(mixed $file)
Convert a single file back into an array.
Parameters
-
\Psr\Http\Message\UploadedFileInterface
$file The file to convert.
Returns
array
convertFiles() protected static
convertFiles(mixed $data, mixed $files, mixed $path)
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 optional The current array path.
Returns
array
Converted file data
getFiles() protected static
getFiles(mixed $request)
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.
getParams() protected static
getParams(\Psr\Http\Message\ServerRequestInterface $request)
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.
toCake() public static
toCake(\Psr\Http\Message\ServerRequestInterface $request)
Transform a PSR7 request into a CakePHP one.
Parameters
-
\Psr\Http\Message\ServerRequestInterface
$request The PSR7 request.
Returns
\Cake\Http\ServerRequest
The transformed request.
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.9/class-Cake.Http.RequestTransformer.html