Skip to content

Commit

Permalink
Merge pull request #2017 from dpfaffenbauer/issues/controller-overwrites
Browse files Browse the repository at this point in the history
[Frontend] fix controller overwriting
  • Loading branch information
dpfaffenbauer authored Jun 10, 2022
2 parents 293a0ea + c2b2408 commit 388e25c
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function process(ContainerBuilder $container): void

foreach ($controllers as $key => $value) {
$controllerKey = sprintf('coreshop.frontend.controller.%s', $key);
$serviceName = sprintf('CoreShop\\Bundle\\FrontendBundle\\Controller\\.%sController', $key);
$serviceName = sprintf('CoreShop\\Bundle\\FrontendBundle\\Controller\\%sController', ucfirst($key));
$controllerClass = (string)$container->getParameter($controllerKey);

if ($container->hasDefinition($controllerClass)) {
Expand Down Expand Up @@ -65,7 +65,7 @@ public function process(ContainerBuilder $container): void
new Reference(ShopperContextInterface::class),
]);

break;
break;
case 'checkout':
$controllerDefinition->setArguments([
new Reference('coreshop.checkout_manager.factory'),
Expand Down Expand Up @@ -96,10 +96,13 @@ public function process(ContainerBuilder $container): void
}

$controllerDefinition->addTag('controller.service_arguments');

$container->setDefinition($serviceName, $controllerDefinition)->setPublic(true);
$container->setAlias($controllerKey, $serviceName)->setPublic(true);

$container->setDefinition($controllerClass, $controllerDefinition);
$container->setAlias($controllerKey, $controllerClass)->setPublic(true);
$container->setAlias($serviceName, $controllerClass)->setPublic(true);
if ($controllerClass !== $serviceName) {
$container->setAlias($controllerClass, $serviceName)->setPublic(true);
}
}
}
}

0 comments on commit 388e25c

Please sign in to comment.