0 follower

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

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

Take data for the input DTO from the query string.

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Input\Http\Attribute\Data\FromQuery
getMap() Get the map of the input DTO property names to the query string data keys. Yiisoft\Input\Http\Attribute\Data\FromQuery
getName() Get the name of the field in the query string to get data from. Yiisoft\Input\Http\Attribute\Data\FromQuery
getResolver() Yiisoft\Input\Http\Attribute\Data\FromQuery
isStrict() Whether to throw an exception if the query string contains data that isn't in the map. Yiisoft\Input\Http\Attribute\Data\FromQuery

Method Details

Hide inherited methods

__construct() public method

public __construct( string|array|null $name null, array $map = [], boolean $strict false ): mixed
$name string|array|null
$map array

Map of the input DTO property names to the query string data keys.

$strict boolean

Whether to throw an exception if the query string 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 query string data keys.

public getMap( ): array
return array

Map of the input DTO property names to the query string data keys.

                public function getMap(): array
{
    return $this->map;
}

            
getName() public method

Get the name of the field in the query string to get data from.

Array means a path. For example, ['user', 'name'] will get data from $body['user']['name']. If null, the whole query string will be used.

public getName( ): array|string|null
return array|string|null

The field in the query string to get data from.

                public function getName(): string|array|null
{
    return $this->name;
}

            
getResolver() public method

public getResolver( ): string

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

            
isStrict() public method

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

public isStrict( ): boolean
return boolean

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

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