Skip to content

Commit 4bdf0c8

Browse files
committed
RoutingExtension: creates service 'routes' only when routes are defined (BC break)
1 parent f0de030 commit 4bdf0c8

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/Bridges/ApplicationDI/RoutingExtension.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ public function __construct(bool $debugMode = false)
4545

4646
public function loadConfiguration()
4747
{
48+
if (!$this->config->routes) {
49+
return;
50+
}
51+
4852
$builder = $this->getContainerBuilder();
4953

5054
$router = $builder->addDefinition($this->prefix('router'))
51-
->setType(Nette\Routing\Router::class)
5255
->setFactory(Nette\Application\Routers\RouteList::class);
5356

5457
if ($this->config->routeClass) {
@@ -88,7 +91,9 @@ public function beforeCompile()
8891
public function afterCompile(Nette\PhpGenerator\ClassType $class)
8992
{
9093
if ($this->config->cache) {
91-
$method = $class->getMethod(Nette\DI\Container::getMethodName($this->prefix('router')));
94+
$builder = $this->getContainerBuilder();
95+
$def = $builder->getDefinitionByType(Nette\Routing\Router::class);
96+
$method = $class->getMethod(Nette\DI\Container::getMethodName($def->getName()));
9297
try {
9398
$router = eval($method->getBody());
9499
if ($router instanceof Nette\Application\Routers\RouteList) {

0 commit comments

Comments
 (0)