Final Class Yiisoft\RequestModel\Attribute\QueryResolver
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| resolve() | Yiisoft\ |
Method Details
| public mixed resolve ( Yiisoft\ | ||
| $attribute | Yiisoft\ |
|
| $request | \ |
|
public function resolve(HandlerParameterAttributeInterface $attribute, ServerRequestInterface $request): mixed
{
if ($attribute::class !== Query::class) {
throw new \InvalidArgumentException(sprintf('Expected "%s", got "%s".', Query::class, $attribute::class));
}
$queryParams = $request->getQueryParams();
if ($attribute->getName() !== null) {
return $queryParams[$attribute->getName()] ?? throw new ValueNotFoundException();
}
return $queryParams;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.