silverstripe/sapphire — pull request #740 by tractorcow (2012-08-26 23:04:50+00:00)
Title: APICHANGE: Changed behaviour of HTTP_Request::params to include route ta...

This pull request is for a "fix" for a gap in the api.

Previously any arguments specified on the routing table would be saved in Director::urlParams() and could be retrieved by the controller. For example, my routes.yml file looks like the below:

```yml
---
Name: translatedroutes
After: framework/routes#rootroutes
---
Director:
rules:
'en_NZ/$URLSegment!//$Action/$ID/$OtherID':
Controller: 'ModelAsController'
Locale: 'en_NZ'
```

In 2.4 the "Locale" parameter would be available, but trying to access this in SS 3.0 via Director::urlParams() gives a deprecation error, noting that SS_HTTPRequest->latestParams() should be used instead. Since only arguments in the url pattern (URLSegment, Action, etc) are actually stored in the request object, this actually represents a degradation in functionality.

My fix is to ensure that during routing these additional parameters are correctly passed to the request object and stored, so that they may be retrieved via $this->request->params().

Note: This pull request is based on a previous attempt to solve this problem which had a few issues involved with it. Hopefully this implementation resolves those issue. :)

The original pull request can be found at https://github.com/silverstripe/sapphire/pull/711 for reference.

This implementation of the problem differs from the original in that it:
* Does not interfere with the HTTP_Request::match function
* Correctly separates the url parameter arguments (specified directly in the url) from the route table arguments.
* Updateds the behaviour of HTTP_Request::param and ::params fuctions to consider both types of parameters
* Includes (working) test cases ^_^