thephpleague/fractal — pull request #114 by joshuajabbour (2014-10-13 22:19:27+00:00)
Title: Allow transformer/resourceKey to come from data.

I'm wondering if a change like this is desirable? It would allow a little more flexibility in initializing resources; I usually extend the Item and Collection classes because they're too verbose for my current usage.

I'm using Laravel, and since my $data is almost always an Eloquent model, I can just have the model provide the default transformer and resourceKey. Obviously, with this change a user could still pass in a transformer to override the default, and a string (or `false` for none) for resourceKey to override that.

This is a sorta breaking change, in that if `$data` has the method `getResourceKey` on it and the user doesn't provide a resourceKey when initializing the resource, then the behavior will have changed from previous versions. (I don't think the same can be said of transformers however, as they were previously required anyway.)

I'll finish out the feature (docs, etc) if this is something you're interested in...