Final Class Yiisoft\Input\Http\Attribute\Data\FromQueryResolver
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Resolver for {@see FromQuery} attribute.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| prepareData() | Yiisoft\ |
Method Details
| public mixed __construct ( \ | ||
| $requestProvider | \ |
The request provider. |
public function __construct(
private RequestProviderInterface $requestProvider,
) {}
| public \ | ||
| $attribute | \ |
|
| $data | \ |
|
public function prepareData(DataAttributeInterface $attribute, DataInterface $data): DataInterface
{
if (!$attribute instanceof FromQuery) {
throw new UnexpectedAttributeException(FromQuery::class, $attribute);
}
$array = [];
$params = $this->requestProvider->get()->getQueryParams();
$name = $attribute->getName();
if ($name === null) {
$array = $params;
} else {
$value = ArrayHelper::getValueByPath($params, $name);
if (is_array($value)) {
$array = $value;
}
}
return new ArrayData($array, $attribute->getMap(), $attribute->isStrict());
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.