Skip to content

Commit

Permalink
RoutingExtension: creates service 'routes' only when routes are defin…
Browse files Browse the repository at this point in the history
…ed (BC break)
  • Loading branch information
dg committed Jul 12, 2020
1 parent 0ef0688 commit 806cba6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Bridges/ApplicationDI/RoutingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public function __construct(bool $debugMode = false)

public function loadConfiguration()
{
if (!$this->config->routes) {
return;
}

$builder = $this->getContainerBuilder();

$router = $builder->addDefinition($this->prefix('router'))
Expand Down Expand Up @@ -86,7 +90,9 @@ public function beforeCompile()
public function afterCompile(Nette\PhpGenerator\ClassType $class)
{
if ($this->config->cache) {
$method = $class->getMethod(Nette\DI\Container::getMethodName($this->prefix('router')));
$builder = $this->getContainerBuilder();
$def = $builder->getDefinitionByType(Nette\Routing\Router::class);
$method = $class->getMethod(Nette\DI\Container::getMethodName($def->getName()));
try {
$router = eval($method->getBody());
if ($router instanceof Nette\Application\Routers\RouteList) {
Expand Down

0 comments on commit 806cba6

Please sign in to comment.