Welcome Guest, Not a member yet? Register   Sign In
Bug in Router
#7

[eluser]dignick[/eluser]
Forget the default controller for each subdirectory.

The bug exists just by specifying only the $route['default_controller']. When visiting the uri which relates to a subdir in controllers, it first determines the route in _validate_request(), and then the route gets set again (unneccessarily) by _set_default_controller(). This functionality is supported, see the documentation:
Quote:Each of your sub-folders may contain a default controller which will be called if the URL contains only the sub-folder

IMO, and in the re-implementation I've done, _validate_controller (I renamed it) does just that - it is passed an array of the segments to be validated and checks if that controller exists. All the actual routing is done in _parse_routes. _set_request sets the internal variables when given an array of segments, and updates uri's rsegments. _set_default_controller is optionally passed a directory and then determines and validates a default route based on the value of $this->default_controller. $segments is always array(directory, controller, method) which avoids confusion. In this implementation there is no feedback between methods.

I have added the ability to set the default controller for each subdirectory, but it could easily be removed. It's all at the bottom of _parse_routes.

Maybe I'm missing things, but this seems like a much simpler way of achieving the same end result.

See the wiki Page


Messages In This Thread
Bug in Router - by El Forum - 03-20-2011, 05:08 PM
Bug in Router - by El Forum - 03-20-2011, 11:26 PM
Bug in Router - by El Forum - 03-21-2011, 04:45 AM
Bug in Router - by El Forum - 03-21-2011, 05:46 AM
Bug in Router - by El Forum - 03-21-2011, 07:44 AM
Bug in Router - by El Forum - 03-21-2011, 10:44 AM
Bug in Router - by El Forum - 03-21-2011, 11:11 AM
Bug in Router - by El Forum - 04-15-2011, 12:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB