willdurand/Hateoas — pull request #56 by jdeveloper (2013-09-18 09:38:04+00:00)
Title: 1.0 Added support to override link definitions when creating collection resource

Hi Will

I'm using the branch of this library to make hyperlinking on REST API. It feeds my needs but I needed to make a collection link based on an object.

Supose I call the url posts/1/comments

But in the collection definition o Comment entity I have the self link configured to the comment_index.

I added a optional argument to the ResourceBuilder::createCollection to override definitions based on the rel attributes.

Example:

$resourceBuilder->createCollection($post->comments, 'AcmeBundle\Entity\Comment',
array(),
array(
array('rel' => 'self', 'definition' => array('route' => 'post_coments', 'parameters' => 'id'), 'data' => $post)
));