Final Class Yiisoft\RequestModel\Attribute\QueryResolver
| Inheritance | Yiisoft\RequestModel\Attribute\QueryResolver |
|---|---|
| Implements | Yiisoft\RequestModel\Attribute\HandlerParameterResolverInterface |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| resolve() | Yiisoft\RequestModel\Attribute\QueryResolver |
Method Details
| public mixed resolve ( Yiisoft\RequestModel\Attribute\HandlerParameterAttributeInterface $attribute, \Psr\Http\Message\ServerRequestInterface $request ) | ||
| $attribute | Yiisoft\RequestModel\Attribute\HandlerParameterAttributeInterface | |
| $request | \Psr\Http\Message\ServerRequestInterface | |
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;
}
Signup or Login in order to comment.