0 follower

Final Class Yiisoft\Input\Http\Attribute\Data\FromBody

InheritanceYiisoft\Input\Http\Attribute\Data\FromBody
ImplementsYiisoft\Hydrator\Attribute\Data\DataAttributeInterface

Take data for the input DTO from the request body.

Public Methods

Hide inherited 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

Hide inherited methods

__construct() public method

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, ['user', 'name'] will get data from $body['user']['name']. If null, the whole body will be used.

$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,
) {
}

            
getMap() public method

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;
}

            
getName() public method

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;
}

            
getResolver() public method

public string getResolver ( )

                public function getResolver(): string
{
    return FromBodyResolver::class;
}

            
isStrict() public method

public boolean isStrict ( )
return boolean

Whether to throw an exception if the request body contains data that isn't in the map.

                public function isStrict(): bool
{
    return $this->strict;
}