File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414use Contributte \Nella \Service \WwwFolder ;
1515use Nette \DI \Definitions \ServiceDefinition ;
1616use Nette \DI \Definitions \Statement ;
17+ use Nette \Routing \SimpleRouter ;
1718
1819class NellaExtension extends CompilerExtension
1920{
@@ -62,9 +63,18 @@ public function beforeCompile(): void
6263 {
6364 $ builder = $ this ->getContainerBuilder ();
6465
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+ }
6878 }
6979
7080}
You can’t perform that action at this time.
0 commit comments