Final Class Yiisoft\Input\Http\Attribute\Parameter\UploadedFilesResolver
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Resolver for {@see UploadedFiles} attribute.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| getParameterValue() | Yiisoft\ |
Method Details
| public mixed __construct ( \ | ||
| $requestProvider | \ |
The request provider. |
public function __construct(
private RequestProviderInterface $requestProvider,
) {}
| public \ | ||
| $attribute | \ |
|
| $context | \ |
|
public function getParameterValue(
ParameterAttributeInterface $attribute,
ParameterAttributeResolveContext $context,
): Result {
if (!$attribute instanceof UploadedFiles) {
throw new UnexpectedAttributeException(UploadedFiles::class, $attribute);
}
$files = $this->requestProvider->get()->getUploadedFiles();
$name = $attribute->getName() ?? $context->getParameter()->getName();
if (!ArrayHelper::pathExists($files, $name)) {
return Result::fail();
}
return Result::success(ArrayHelper::getValueByPath($files, $name));
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.