Restful
Restful copied to clipboard
Is it necessary to scan ALL robot-loaded files in RouteListFactory?
I've been debugging the URL composing issues and noticed this.
RouteListFactory
scans all the classes loaded by RobotLoader under the 'presentersRoot' in order to find routes in annotations at line 91. Its caller class, CachedRouteListFactory
already finds the presenters where the routes might be found, at line 50. The problem is that the interface doesn't support specifying the files where to look for routes.
It seems to me that scanning all files may be unnecessary in this case because the RobotLoader may have a large list of files and only few of them are actually those we are looking for. Even though it only happens on cache rebuild.
By posting this issue I'm trying to start a discussion or get directions (maybe I'm not seeing a bigger idea behind whole this). I may provide a pull request if it gets anywhere.
Presenters dir cold be changed by undocumented config.neon option:
restful: routes: presentersRoot: '%appDir%/presenters/REST'
I've found another bug. In the RouteListFactory constructor is directly used RobotLoader(). Bud there is no calling of the method $loader->register(). So, cached robot loader data are not loaded, and everytime it is rebuilded again, and again...
I noticed the repeated rebuilds too, but it's been some time ago and I don't remember whether I did dig deeper to see what's going on.
Also, good catch that the presentersRoot
may be loaded from config, though it won't help much if the application is composed from several modules, unless the presentersRoot
can be made array, in which case it may just complicate things a lot more.
@brabo-dan I found this problem some time ago. I was not able to handle it as I would like to, but at least there is a config option to disable that behavior https://github.com/drahak/Restful/pull/92