update patch 1
This commit is contained in:
@@ -34,16 +34,17 @@ final class ArgumentResolver implements ArgumentResolverInterface
|
||||
{
|
||||
private ArgumentMetadataFactoryInterface $argumentMetadataFactory;
|
||||
private iterable $argumentValueResolvers;
|
||||
private ?ContainerInterface $namedResolvers;
|
||||
|
||||
/**
|
||||
* @param iterable<mixed, ValueResolverInterface> $argumentValueResolvers
|
||||
*/
|
||||
public function __construct(?ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, iterable $argumentValueResolvers = [], ?ContainerInterface $namedResolvers = null)
|
||||
{
|
||||
public function __construct(
|
||||
?ArgumentMetadataFactoryInterface $argumentMetadataFactory = null,
|
||||
iterable $argumentValueResolvers = [],
|
||||
private ?ContainerInterface $namedResolvers = null,
|
||||
) {
|
||||
$this->argumentMetadataFactory = $argumentMetadataFactory ?? new ArgumentMetadataFactory();
|
||||
$this->argumentValueResolvers = $argumentValueResolvers ?: self::getDefaultArgumentValueResolvers();
|
||||
$this->namedResolvers = $namedResolvers;
|
||||
}
|
||||
|
||||
public function getArguments(Request $request, callable $controller, ?\ReflectionFunctionAbstract $reflector = null): array
|
||||
@@ -60,7 +61,7 @@ final class ArgumentResolver implements ArgumentResolverInterface
|
||||
if ($attribute->disabled) {
|
||||
$disabledResolvers[$attribute->resolver] = true;
|
||||
} elseif ($resolverName) {
|
||||
throw new \LogicException(sprintf('You can only pin one resolver per argument, but argument "$%s" of "%s()" has more.', $metadata->getName(), $metadata->getControllerName()));
|
||||
throw new \LogicException(\sprintf('You can only pin one resolver per argument, but argument "$%s" of "%s()" has more.', $metadata->getName(), $metadata->getControllerName()));
|
||||
} else {
|
||||
$resolverName = $attribute->resolver;
|
||||
}
|
||||
@@ -96,7 +97,7 @@ final class ArgumentResolver implements ArgumentResolverInterface
|
||||
}
|
||||
|
||||
if (1 < $count && !$metadata->isVariadic()) {
|
||||
throw new \InvalidArgumentException(sprintf('"%s::resolve()" must yield at most one value for non-variadic arguments.', get_debug_type($resolver)));
|
||||
throw new \InvalidArgumentException(\sprintf('"%s::resolve()" must yield at most one value for non-variadic arguments.', get_debug_type($resolver)));
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
@@ -118,7 +119,7 @@ final class ArgumentResolver implements ArgumentResolverInterface
|
||||
}
|
||||
}
|
||||
|
||||
throw new \RuntimeException(sprintf('Controller "%s" requires the "$%s" argument that could not be resolved. '.($reasonCounter > 1 ? 'Possible reasons: ' : '').'%s', $metadata->getControllerName(), $metadata->getName(), implode(' ', $reasons)));
|
||||
throw new \RuntimeException(\sprintf('Controller "%s" requires the "$%s" argument that could not be resolved. '.($reasonCounter > 1 ? 'Possible reasons: ' : '').'%s', $metadata->getControllerName(), $metadata->getName(), implode(' ', $reasons)));
|
||||
}
|
||||
|
||||
return $arguments;
|
||||
|
||||
Reference in New Issue
Block a user