Final Class Yiisoft\Input\Http\Attribute\Data\FromBody
| Inheritance | Yiisoft\Input\Http\Attribute\Data\FromBody |
|---|---|
| Implements | Yiisoft\Hydrator\Attribute\Data\DataAttributeInterface |
Take data for the input DTO from the request body.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Input\Http\Attribute\Data\FromBody | |
| getMap() | Get the map of the input DTO property names to the request body data keys. | Yiisoft\Input\Http\Attribute\Data\FromBody |
| getName() | Get the name of the field in the request body to get data from. | Yiisoft\Input\Http\Attribute\Data\FromBody |
| getResolver() | Yiisoft\Input\Http\Attribute\Data\FromBody | |
| isStrict() | Yiisoft\Input\Http\Attribute\Data\FromBody |
Method Details
| public mixed __construct ( array|string|null $name = null, array $map = [], boolean $strict = false ) | ||
| $name | array|string|null |
The field in the request body to get data from.
Array means a path.
For example, |
| $map | array |
Map of the input DTO property names to the request body data keys. |
| $strict | boolean |
Whether to throw an exception if the request body contains data that isn't in the map. |
public function __construct(
private string|array|null $name = null,
private array $map = [],
private bool $strict = false,
) {
}
Get the map of the input DTO property names to the request body data keys.
| public array getMap ( ) | ||
| return | array |
Map of the input DTO property names to the request body data keys. |
|---|---|---|
public function getMap(): array
{
return $this->map;
}
Get the name of the field in the request body to get data from.
Array means a path.
For example, ['user', 'name'] will get data from $body['user']['name'].
If null, the whole body will be used.
| public array|string|null getName ( ) | ||
| return | array|string|null |
The field in the request body to get data from. |
|---|---|---|
public function getName(): string|array|null
{
return $this->name;
}
| public string getResolver ( ) |
public function getResolver(): string
{
return FromBodyResolver::class;
}
Signup or Login in order to comment.