Seems I haven't created an issue for this, yet. I need an issue to point people to who complain to me about this, though.

The problem is the following: Say, I want all properties that are theoretically available for entities of a certain type (without having an actual entity, yet). When creating a wrapper, I can specify a 'property info alter' callback and use entity_get_all_property_info() to add all fields to the wrapper, including ones set only for some bundles.
However, when the entity contains a reference to another entity, there is at the moment no (not unnecessarily complicated) way to also get all fields of that referenced entity, including ones set on bundles.

Some way to accomplish this would be great.
It could either be another property info alter callback, which also gets called for nested entities, or just a single flag that says "get me all fields for all entities", or something else entirely.

Comments

imiksu’s picture

Subscribe :)

zambrey’s picture

Subscribe

fago’s picture

There is not only property info alter, but there is also a property defaults key. Thus, you can use the property defaults key to set a property info alter callback by default for all derived wrappers, i.e. wrappers of all properties and so of referenced entities too.

drunken monkey’s picture

Ah, really, that's how it works? That's of course great, will try that.
Does this also work for wrappers derived from the derived wrappers (and so forth)?

fago’s picture

>Does this also work for wrappers derived from the derived wrappers (and so forth)?
Good question - I think you'll have to care manually to pass the property defaults down. It would make sense to do that by default I guess, so I'd be happy to accept a little patch that passed the property defaults through.

zambrey’s picture

You guys rock! I don't know what you are saying but keep up great work :)
Maybe one day I will have more time to learn all this things and will be able to help more.

drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new814 bytes

Good question - I think you'll have to care manually to pass the property defaults down. It would make sense to do that by default I guess, so I'd be happy to accept a little patch that passed the property defaults through.

OK, giving it a shot with the attached patch.

zambrey’s picture

Thanks for the patch.
I would like test this but first I need to understand what's going on here.
I came from #1214862: Custom fields not available on referred contents as I would like to use fields defined in Commerce Product in SearchAPI.
The OP in that issue described the situation clearly.

I applied this patch but nothing changes.
Do we need separate fix in SearchAPI or this issue should fix everything?

fago’s picture

Patch looks good. If it helps you to fix the problem I'm happy to commit it. Please report when there is a working solution.

drunken monkey’s picture

I applied this patch but nothing changes.
Do we need separate fix in SearchAPI or this issue should fix everything?

This patch is only a prerequisite for fixing this in the Search API. I'll make a patch for the Search API soon, then you can test this.

zambrey’s picture

Okay, thanks for clarification and sorry for the noise.

drunken monkey’s picture

Status: Needs review » Reviewed & tested by the community

Not at all, I'm happy to clarify. Thanks for helping with the review!

@ Wolfgang: Just committed the Search API patch, seems to work great with this patch. So if you have no objections, it's ready to be committed.

imiksu’s picture

Thanks for the patch, working great together with patch committed in Search API issue!

fago’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.