Final Class Yiisoft\Router\HydratorAttribute\RouteArgumentResolver
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| getParameterValue() | Yiisoft\ |
Method Details
| public mixed __construct ( Yiisoft\ | ||
| $currentRoute | Yiisoft\ |
|
public function __construct(
private readonly CurrentRoute $currentRoute,
) {}
| public \ | ||
| $attribute | \ |
|
| $context | \ |
|
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();
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.