symfony-cmf/Routing — pull request #18 by lolautruche (2012-09-21 14:15:13+00:00)
Title: Fixed #15 When using the chain router in a compiler pass, cache warmup fails

# Origin of the issue

When warming up, base `UrlMatcher` / `UrlGenerator` are "cached" by the routing component. The **CMF ChainRouter** adds its routers in a compiler pass through its `add()` method. But calling this method triggers `setContext()` which triggers again `UrlMatcher` caching process, thus the collision and the fatal error.

# Proposed fix

As `add()` is called at compile/warmup time, the best solution would be to move the `setContext()` operation to a safer place, that is in `all()`, just after the routers has been sorted (only happens once, unless a new router is added on the fly).