zendframework/zf2 — pull request #966 by Thinkscape (2012-03-24 17:37:02+00:00)
Title: Refactor RouteMatch, add InjectRouteMatchListener.

This PR depends on PR #963
## Rationale
This change makes `RouteMatch` a parameter object, same as Request and Response params. It can now be traversed and accessed in the same way as params (arguments) from other sources (i.e. post, query, console etc.)

The `InjectRouteMatchListener` takes the refactored RouteMatch and attaches it to `Request`. This allows for the following usage inside controllers:

````php
"/article[/:category]/:name"
*/
class IndexController {
public function indexAction(){
if(isset($this->request->routeMatch->category){
echo "Current category: ";
echo $this->request->routeMatch->category;
echo "\n";
}

echo "Selected article: ";
echo $this->request->routeMatch->name;
echo "\n";

foreach($this->request->routeMatch as $param => $val){
echo $param." = ".$val."
":
}
}
}
````

## Description of changes

* Router\RouteMatch is now a subclass of Stdlib\Parameter.
* Add `Mvc\View\InjectRouteMatchListener` that attaches to 'dispatch' event and injects RouteMatch object into the MvcEvent Request instance.
* Change `Stdlib\Request` to allow injecting RouteMatch objects and access it in same style as post() and get() argument collections in `Http\Request`.
* Refactor all dependent components to use `RouteMatch::get()` instead of `::getParam()`.
* Refactor all dependent components to use `RouteMatch::set()` instead of `::setParam()`.
* Refactor all dependent components to use `RouteMatch::toArray()` instead of `::getParams()`.