Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Use _links instead of unrendered embedded entity #119

Closed
wants to merge 5 commits into from
Closed

Use _links instead of unrendered embedded entity #119

wants to merge 5 commits into from

Conversation

nobesnickr
Copy link

This is an exploratory pull request to get feedback and explore a solution

Adding option to use the rendered resources _link object for related/embedded entities when render
embedded resources is set to false.

…embedded entities when render embedded resources is set to false.
@nobesnickr nobesnickr changed the title #118 Use _links instead of unrendered embedded entity Use _links instead of unrendered embedded entity Aug 30, 2015
@weierophinney weierophinney added this to the 1.4.0 milestone Jul 6, 2016
@weierophinney weierophinney self-assigned this Jul 6, 2016
@weierophinney weierophinney removed this from the 1.4.0 milestone Jul 6, 2016
@weierophinney
Copy link
Member

I like this idea. Because it's based off a setting in the helper, individual controllers can also opt-in to the workflow, allowing keeping the original behavior as the default, but selectively opting into the new behavior as particular resources require it.

A few things:

  • Please rebase.
  • Please add tests.

Thanks!

@Wilt
Copy link
Contributor

Wilt commented Aug 11, 2016

We also didn't like the unrendered embedded entity solution and wanted to use links instead.

In the end we solved this by linking all related resources (embedded and not embedded ones). In our current solution we don't have to worry at all about wheter a resource is embedded or not, since links for all related resources are always included in the response. If client needs the resource it checks whether it is embedded if not, there is always the link that can be used for resolving it...

Maybe this is a nice (and more easily implementable) alternative solution...

BTW this issue is very much related to a previous issue: #118

We are using doctrine, and we managed to take this solution to the level where proxies (entities not resolved from the database) are always linked (using the entity id from the proxy) and resolved resources are embedded only once (every other instance is linked).

If we want to add an entity into our HAL response all we need to do is add fetch-join in our entity repository for the entity that we are interested in and it is automatically embedded in the response (we get a a full entity not a proxy, thus it will be embedded)...

@weierophinney
Copy link
Member

Closing due to inactivity, and conflicts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants