Skip to content

Commit 1ae86e7

Browse files
committed
Use page controller from container if registered
1 parent 2ff31bc commit 1ae86e7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Page/PageContext/PageControllerContext.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
99
use Symfony\Component\DependencyInjection\ContainerInterface;
1010

11-
1211
class PageControllerContext implements PageContextProviderInterface
1312
{
1413

@@ -49,7 +48,9 @@ public function getContextValue(HasNodeInterface $page, array $context)
4948
}
5049

5150
/** @var PageControllerInterface|ContainerAwareInterface $controller */
52-
$controller = new $controllerClass;
51+
$controller = $this->container->has($controllerClass)
52+
? $this->container->get($controllerClass)
53+
: new $controllerClass;
5354

5455
if (false === $controller instanceof PageControllerInterface) {
5556
throw new \RuntimeException("$controllerClass needs to implement " . PageControllerInterface::class);
@@ -61,4 +62,5 @@ public function getContextValue(HasNodeInterface $page, array $context)
6162

6263
return $controller->serviceAction($page, $context);
6364
}
65+
6466
}

0 commit comments

Comments
 (0)