🔧
This commit is contained in:
@@ -30,7 +30,9 @@ class LoggerPass implements CompilerPassInterface
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$container->setAlias(LoggerInterface::class, 'logger');
|
||||
if (!$container->has(LoggerInterface::class)) {
|
||||
$container->setAlias(LoggerInterface::class, 'logger');
|
||||
}
|
||||
|
||||
if ($container->has('logger')) {
|
||||
return;
|
||||
|
||||
@@ -45,6 +45,7 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
|
||||
$parameterBag = $container->getParameterBag();
|
||||
$controllers = [];
|
||||
$controllerClasses = [];
|
||||
|
||||
$publicAliases = [];
|
||||
foreach ($container->getAliases() as $id => $alias) {
|
||||
@@ -58,6 +59,7 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
foreach ($container->findTaggedServiceIds('controller.service_arguments', true) as $id => $tags) {
|
||||
$def = $container->getDefinition($id);
|
||||
$def->setPublic(true);
|
||||
$def->setLazy(false);
|
||||
$class = $def->getClass();
|
||||
$autowire = $def->isAutowired();
|
||||
$bindings = $def->getBindings();
|
||||
@@ -74,6 +76,8 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
|
||||
}
|
||||
|
||||
$controllerClasses[] = $class;
|
||||
|
||||
// get regular public methods
|
||||
$methods = [];
|
||||
$arguments = [];
|
||||
@@ -155,7 +159,7 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
continue;
|
||||
} elseif (!$autowire || (!($autowireAttributes ??= $p->getAttributes(Autowire::class, \ReflectionAttribute::IS_INSTANCEOF)) && (!$type || '\\' !== $target[0]))) {
|
||||
continue;
|
||||
} elseif (is_subclass_of($type, \UnitEnum::class)) {
|
||||
} elseif (!$autowireAttributes && is_subclass_of($type, \UnitEnum::class)) {
|
||||
// do not attempt to register enum typed arguments if not already present in bindings
|
||||
continue;
|
||||
} elseif (!$p->allowsNull()) {
|
||||
@@ -227,5 +231,10 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
}
|
||||
|
||||
$container->setAlias('argument_resolver.controller_locator', (string) $controllerLocatorRef);
|
||||
|
||||
if ($container->hasDefinition('controller_resolver')) {
|
||||
$container->getDefinition('controller_resolver')
|
||||
->addMethodCall('allowControllers', [array_unique($controllerClasses)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user