0 follower

Final Class Yiisoft\RequestModel\Attribute\RequestResolver

InheritanceYiisoft\RequestModel\Attribute\RequestResolver
ImplementsYiisoft\RequestModel\Attribute\HandlerParameterResolverInterface

Method Details

Hide inherited methods

resolve() public method

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 !== 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;
}