lazyyyyy
continuous-integration/drone/push Build encountered an error
Details
continuous-integration/drone/push Build encountered an error
Details
parent
689c7352e6
commit
8578d148a2
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
public function getArguments(Request $request, callable $controller, \ReflectionFunctionAbstract $reflector = null): array
|
||||||
|
{
|
||||||
|
$arguments = [];
|
||||||
|
|
||||||
|
foreach ($this->argumentMetadataFactory->createArgumentMetadata($controller, $reflector) as $metadata) {
|
||||||
|
$argumentValueResolvers = $this->argumentValueResolvers;
|
||||||
|
$disabledResolvers = [];
|
||||||
|
|
||||||
|
if ($this->namedResolvers && $attributes = $metadata->getAttributesOfType(ValueResolver::class, $metadata::IS_INSTANCEOF)) {
|
||||||
|
$resolverName = null;
|
||||||
|
foreach ($attributes as $attribute) {
|
||||||
|
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(), $this->getPrettyName($controller)));
|
||||||
|
} else {
|
||||||
|
$resolverName = $attribute->resolver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($resolverName) {
|
||||||
|
if (!$this->namedResolvers->has($resolverName)) {
|
||||||
|
throw new ResolverNotFoundException($resolverName, $this->namedResolvers instanceof ServiceProviderInterface ? array_keys($this->namedResolvers->getProvidedServices()) : []);
|
||||||
|
}
|
||||||
|
|
||||||
|
$argumentValueResolvers = [
|
||||||
|
$this->namedResolvers->get($resolverName),
|
||||||
|
new DefaultValueResolver(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($argumentValueResolvers as $name => $resolver) {
|
||||||
|
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
foreach ($resolver->resolve($request, $metadata) as $argument) {
|
||||||
|
++$count;
|
||||||
|
$arguments[] = $argument;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or there is a non-optional argument after this one.', $this->getPrettyName($controller), $metadata->getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arguments;
|
||||||
|
}
|
Loading…
Reference in new issue