Final Class Yiisoft\RequestModel\Attribute\RequestResolver
| 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 !== Request::class) {
throw new \InvalidArgumentException(sprintf('Expected "%s", got "%s".', Request::class, $attribute::class));
}
$notFoundValue = NotFoundValue::getInstance();
/** @var mixed $result */
$result = $request->getAttribute($attribute->getName(), $notFoundValue);
if ($result === $notFoundValue) {
throw new ValueNotFoundException();
}
return $result;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.