BodyParsingMiddleware
extends Middleware
in package
implements
MiddlewareInterface
Request body parsing
Table of Contents
Interfaces
- MiddlewareInterface
- Middleware interface
Properties
- $container : ContainerInterface|null
- Container
- $options : array<string|int, mixed>
- Middleware options
- $parsers : array<string|int, callable>
Methods
- __construct() : mixed
- Constructor
- getOption() : mixed|null
- Get option value
- getOptions() : array<string|int, mixed>
- Return all options
- getParser() : callable|null
- Get parser
- hasBodyParser() : bool
- Return true if parser exist
- process() : array<string|int, mixed>
- Process middleware
- registerBodyParser() : void
- Register parser
- setOption() : void
- Set option
- withOption() : Middleware
- Set option
- getMediaType() : string|null
- Get media type
- parseBody() : null|array<string|int, mixed>|object
- Parse body
- registerDefaultBodyParsers() : void
- Register default parsers
Properties
$container
Container
protected
ContainerInterface|null
$container
= null
$options
Middleware options
protected
array<string|int, mixed>
$options
= []
$parsers
protected
array<string|int, callable>
$parsers
Methods
__construct()
Constructor
public
__construct([ContainerInterface|null $container = null ][, array<string|int, mixed>|null $options = [] ]) : mixed
Parameters
- $container : ContainerInterface|null = null
- $options : array<string|int, mixed>|null = []
getOption()
Get option value
public
getOption(string $name[, mixed $default = null ]) : mixed|null
Parameters
- $name : string
- $default : mixed = null
Return values
mixed|nullgetOptions()
Return all options
public
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getParser()
Get parser
public
getParser(string $mediaType) : callable|null
Parameters
- $mediaType : string
Tags
Return values
callable|nullhasBodyParser()
Return true if parser exist
public
hasBodyParser(string $mediaType) : bool
Parameters
- $mediaType : string
Return values
boolprocess()
Process middleware
public
process(ServerRequestInterface $request, ResponseInterface $response) : array<string|int, mixed>
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
Return values
array<string|int, mixed> —[$request,$response]
registerBodyParser()
Register parser
public
registerBodyParser(string $mediaType, callable $callable) : void
Parameters
- $mediaType : string
- $callable : callable
setOption()
Set option
public
setOption(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
withOption()
Set option
public
withOption(string $name, mixed $value) : Middleware
Parameters
- $name : string
- $value : mixed
Return values
MiddlewaregetMediaType()
Get media type
protected
getMediaType(ServerRequestInterface $request) : string|null
Parameters
- $request : ServerRequestInterface
Return values
string|nullparseBody()
Parse body
protected
parseBody(ServerRequestInterface $request) : null|array<string|int, mixed>|object
Parameters
- $request : ServerRequestInterface
Return values
null|array<string|int, mixed>|objectregisterDefaultBodyParsers()
Register default parsers
protected
registerDefaultBodyParsers() : void