WoltLab/WCF — pull request #360 by Gravatronics (2012-01-03 20:31:41+00:00)
Title: Makes route system more complex

This pull request takes the idea of controller-less routes "to the next level". Let's take a look how it works:

First of all, routes are registered via a PIP with the default routes installed during the setup of WCF. The basic behavior didn't change, when a request takes place, all routes are checked, the first that matches wins and the correct controller is created. The new thing is how links are created using the `link`-template plugin. If you use `controller` as a string, everything is still the same. If you want to use an implementation of `IRouteController` (which is basicly a new interface since the two methods are new ones; the old ones don't exist anymore), things changed a bit: The controller is the database object: `{link controller=$dboWhichImplementsIRouteController}{/link}`.

So, let's take a look at an example: a bugtracker where you have different packages, each with an unique identifier like `com.woltlab.wcf`. Now, you want to call the package with all bug reports and suggestions this way: `domain.com/bugtracker/com.woltlab.wcf/` and want to build all links within templates this way. With the current system, that's not possible, the new system allows this.

First of all, you define a new route:

```XML

/{packageIdentifier}/
(\/|\-|\_)

[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+

```

Most things should be clear since they only reflect current method parameters. `partspattern` is new and is used by the route object to cut request urls and the route schema into pieces. This is necessary since the default pattern also uses points for cutting which in our case wouldn't be what we want - in general it makes the system more flexible.

Now, the `Package` class would look like this (only needed parts):

```PHP
$this->packageIdentifier
);
}

/**
* @see	wcf\system\route\IRouteController::getRouteName()
*/
public function getRouteName() {
return 'com.woltlab.wbt.package';
}
}
```

The object says which route it wants to be used and delivers the values used to build the route using the route schema.

I tested it as much as possible but without connected applications and I hope that there's no bug left. Have fun and be gracious ;).