Final Class Yiisoft\Router\HydratorAttribute\RouteArgumentResolver
| Inheritance | Yiisoft\Router\HydratorAttribute\RouteArgumentResolver |
|---|---|
| Implements | Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeResolverInterface |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Router\HydratorAttribute\RouteArgumentResolver | |
| getParameterValue() | Yiisoft\Router\HydratorAttribute\RouteArgumentResolver |
Method Details
| public mixed __construct ( Yiisoft\Router\CurrentRoute $currentRoute ) | ||
| $currentRoute | Yiisoft\Router\CurrentRoute | |
public function __construct(
private readonly CurrentRoute $currentRoute,
) {
}
| public \Yiisoft\Hydrator\Result getParameterValue ( \Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface $attribute, \Yiisoft\Hydrator\AttributeHandling\ParameterAttributeResolveContext $context ) | ||
| $attribute | \Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface | |
| $context | \Yiisoft\Hydrator\AttributeHandling\ParameterAttributeResolveContext | |
public function getParameterValue(
ParameterAttributeInterface $attribute,
ParameterAttributeResolveContext $context,
): Result {
if (!$attribute instanceof RouteArgument) {
throw new UnexpectedAttributeException(RouteArgument::class, $attribute);
}
$arguments = $this->currentRoute->getArguments();
$name = $attribute->getName() ?? $context->getParameter()->getName();
if (array_key_exists($name, $arguments)) {
return Result::success($arguments[$name]);
}
return Result::fail();
}
Signup or Login in order to comment.