File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 14
14
use Contributte \Nella \Service \WwwFolder ;
15
15
use Nette \DI \Definitions \ServiceDefinition ;
16
16
use Nette \DI \Definitions \Statement ;
17
+ use Nette \Routing \SimpleRouter ;
17
18
18
19
class NellaExtension extends CompilerExtension
19
20
{
@@ -62,9 +63,18 @@ public function beforeCompile(): void
62
63
{
63
64
$ builder = $ this ->getContainerBuilder ();
64
65
65
- $ routerDef = $ builder ->getDefinition ('routing.router ' );
66
- assert ($ routerDef instanceof ServiceDefinition);
67
- $ routerDef ->setFactory (new Statement ($ this ->prefix ('@routerFactory::create ' )));
66
+ if ($ builder ->hasDefinition ('routing.router ' )) {
67
+ $ routerDef = $ builder ->getDefinition ('routing.router ' );
68
+ assert ($ routerDef instanceof ServiceDefinition);
69
+
70
+ // Only replace if default SimpleRouter is used
71
+ if ($ routerDef ->getCreator ()->getEntity () === SimpleRouter::class) {
72
+ $ routerDef ->setFactory (new Statement ($ this ->prefix ('@routerFactory::create ' )));
73
+ }
74
+ } else {
75
+ $ routerDef = $ builder ->addDefinition ('routing.router ' );
76
+ $ routerDef ->setFactory (new Statement ($ this ->prefix ('@routerFactory::create ' )));
77
+ }
68
78
}
69
79
70
80
}
You can’t perform that action at this time.
0 commit comments