joomla/joomla-framework — pull request #342 by dongilbert (2014-02-03 06:00:02+00:00)
Title: Refactor Router to allow abitrary callables and remove dependency on Controller and Input

This PR implements a simplified Router class that does not depend on our Input or Controller classes to function.

The changed functionality is as such:
- Remove `RestRouter` since it's tied to a single-action controller method
- Remove `fetchController`, `setDefaultController` and family
- Use `parseRoute($route)` instead of `getController($route)`
- Returned value is no longer an instance of the controller class, but rather an array structured as:
```php
$returnedArray = [
'controller' => 'nameOfControllerOrCallableOrClosureInstance',
'vars' => [
// vars extracted from route, including `_rawRoute`
]
];
```

This greatly decouples the `Router` class, and makes it a standalone routing package, that is not tied to any implementation, and it's more flexible. It leaves the actual instantiation and variable setting to the calling code, which allows for more flexible implementations.

What do you think? I'm not sure this is ready yet, but would like to start the discussion with some code.