Introduce buildURLForHasMany hook

**Not ready for merge**

This introduces a new hook, `buildURLForHasMany`, to address the issues discussed in #2162. I'm running out the door at the moment, but I'll fill this in with more details shortly.