Closed Andrewsville closed 8 years ago
@Andrewsville is this still an issue after https://github.com/Kdyby/Console/pull/42 ?
If it is, please drop me a line here and we can discuss it further :)
Yes, it is. #42 solves a somewhat related but different issue. #42 is about "not having to have nette/application
as dependency". This issue is about "not having to have the application router an instance of RouteList
but an IRouter
".
Recently we've run into the problem that
Kdyby\Console
is not happy with a router being anIRouter
but insist it has to be aRouteList
.Unfortunatelly, in our case that is not technically possible. And even if it was (we can subclass the
RouteList
, right), the whole reason it has to be (to be able to prepend theCliRouter
to the router list) wouldn't work anyway.It is obvious that the whole reason for the
CliRouter
is that one is able to fire up the Nette app from the console just like from the browser and it redirects its requests to theKdyby\Console\Application
via theCliPresenter
.I have two possible solutions.
Kdyby\Console\Application
directly when in CLI. So we don't need to modify the router in the first place.RouteList
.RouteList
instance, where the first route is yourCliRouter
and the second is the originalIRoute
implementation.The second solution looks way better to me (although there is probably a cave eat - if other DI extensions modify the router too, the
ConsoleExtension
would have to be the last because this modification would (could?) not be done at run time but at DIC compile time. Anyway, I can prepare a pull request if you decide to go that way.