Skip to content

Commit 77fe910

Browse files
committed
RoutingExtension: creates service 'routes' only when routes are defined (BC break)
1 parent 34d3951 commit 77fe910

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
@@ -42,10 +42,13 @@ public function __construct(bool $debugMode = false)
4242

4343
public function loadConfiguration()
4444
{
45+
if (!$this->config->routes) {
46+
return;
47+
}
48+
4549
$builder = $this->getContainerBuilder();
4650

4751
$router = $builder->addDefinition($this->prefix('router'))
48-
->setType(Nette\Routing\Router::class)
4952
->setFactory(Nette\Application\Routers\RouteList::class);
5053

5154
if ($this->config->routeClass) {
@@ -85,7 +88,9 @@ public function beforeCompile()
8588
public function afterCompile(Nette\PhpGenerator\ClassType $class)
8689
{
8790
if ($this->config->cache) {
88-
$method = $class->getMethod(Nette\DI\Container::getMethodName($this->prefix('router')));
91+
$builder = $this->getContainerBuilder();
92+
$def = $builder->getDefinitionByType(Nette\Routing\Router::class);
93+
$method = $class->getMethod(Nette\DI\Container::getMethodName($def->getName()));
8994
try {
9095
$router = eval($method->getBody());
9196
if ($router instanceof Nette\Application\Routers\RouteList) {

0 commit comments

Comments
 (0)