[Controller][ServiceValueResolver] Making method access case insensitive
This commit is contained in:
parent
5632dc7c7a
commit
cc6f82769b
@ -47,6 +47,10 @@ final class ServiceValueResolver implements ArgumentValueResolverInterface
|
|||||||
$controller = ltrim($controller, '\\');
|
$controller = ltrim($controller, '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->container->has($controller) && false !== $i = strrpos($controller, ':')) {
|
||||||
|
$controller = substr($controller, 0, $i).strtolower(substr($controller, $i));
|
||||||
|
}
|
||||||
|
|
||||||
return $this->container->has($controller) && $this->container->get($controller)->has($argument->getName());
|
return $this->container->has($controller) && $this->container->get($controller)->has($argument->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +67,11 @@ final class ServiceValueResolver implements ArgumentValueResolverInterface
|
|||||||
$controller = ltrim($controller, '\\');
|
$controller = ltrim($controller, '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->container->has($controller)) {
|
||||||
|
$i = strrpos($controller, ':');
|
||||||
|
$controller = substr($controller, 0, $i).strtolower(substr($controller, $i));
|
||||||
|
}
|
||||||
|
|
||||||
yield $this->container->get($controller)->get($argument->getName());
|
yield $this->container->get($controller)->get($argument->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,24 @@ class ServiceValueResolverTest extends TestCase
|
|||||||
$this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument));
|
$this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testExistingControllerWithMethodNameStartUppercase()
|
||||||
|
{
|
||||||
|
$resolver = new ServiceValueResolver(new ServiceLocator(array(
|
||||||
|
'App\\Controller\\Mine::method' => function () {
|
||||||
|
return new ServiceLocator(array(
|
||||||
|
'dummy' => function () {
|
||||||
|
return new DummyService();
|
||||||
|
},
|
||||||
|
));
|
||||||
|
},
|
||||||
|
)));
|
||||||
|
$request = $this->requestWithAttributes(array('_controller' => 'App\\Controller\\Mine::Method'));
|
||||||
|
$argument = new ArgumentMetadata('dummy', DummyService::class, false, false, null);
|
||||||
|
|
||||||
|
$this->assertTrue($resolver->supports($request, $argument));
|
||||||
|
$this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument));
|
||||||
|
}
|
||||||
|
|
||||||
public function testControllerNameIsAnArray()
|
public function testControllerNameIsAnArray()
|
||||||
{
|
{
|
||||||
$resolver = new ServiceValueResolver(new ServiceLocator(array(
|
$resolver = new ServiceValueResolver(new ServiceLocator(array(
|
||||||
|
Reference in New Issue
Block a user