I have a client who needs to do data comparison on a field provided by Media module. Currently it isn't showing up in Rules' entity picker, I think because this module isn't plugged in with Entity API, and Rules requires Entity API to know about entities provided by a module to do its magic. (See http://drupal.org/node/878880)

I propose an optional block of code that does just that, not to replicate the entity provisioning this module is currently doing, but to enable this additional cross-contrib compatibility.

I'm creating this ticket to 1) See if anyone has run into a similar requirement and was able to work around it using the existing code or 2) determine if there's already a patch in the works. I will probably work up a patch in the next few days if this is indeed the route we choose for our particular use case.

Comments

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

Media no longer provides its own entity type and only uses file entities. So I'm not exactly sure what we have to do here in Media.

bradjones1’s picture

Hi Dave - any thoughts on why these entities aren't available to Rules, then? Perhaps my speculation as to the cause of this problem is wrong?

Rules requires metadata from Entity API, which isn't a requirement for Media module as far as I can tell.

bradjones1’s picture

Status: Postponed (maintainer needs more info) » Postponed

Edit: It looks like the work needs to happen at #1303428: Rules support for file_entity

Postponing, pending successful fix over at file_entity.

bradjones1’s picture

Status: Postponed » Needs review
StatusFileSize
new562 bytes

I've done a bit more digging and here's what I've discovered. The issue is indeed with Entity API, but it's not a problem with the underlying entity_file module's implementation. Since file entity is originally provided by core, Rules already knows about it. The problem is that the field created by mediafield module isn't seen by Entity API because of the issue described at http://drupal.org/node/1156554 - the mediafield_field_info() implementation needs to include a property_type definition. There is little to no documentation on accepted values, but 'file' seems to work.

Take a look. In Rules, you're able to drill in to the file object and pick out fid, file name, etc.

sun’s picture

Issue tags: -entity API +Entity system
dave reid’s picture

I don't use Rules so it would be good to get some confirmation from others that this is the appropriate solution.

agentrickard’s picture

Given that Media Field module is deprecated, I don't see how this patch helps.

As a new (potential) user of Rules, I would expect to see File events, but they do not seem to exist.

dave reid’s picture

Title: Rules module integration » Entity API (and Rules) integration for mediafield
Component: Code » Media field
bradjones1’s picture

Status: Needs review » Closed (fixed)

Re: #7, good point - I rolled this patch for a client who was/is still using mediafield and I figured I'd share it here for anyone in the same boat. But if it's no longer in the module, no reason for review/commit.

I'll close as fixed, since I think it at least does what it advertises. Thanks.

dave reid’s picture

Status: Closed (fixed) » Needs work

I'm still open to adding this code, but the patch seems to differ with #1404720: Integrate Mediafield submodule with Entity Framework in how this should be implemented.

davidseth’s picture

I would still add the code, but use

'property_type' => 'field_item_file'

as that is what the Entity module uses for File type.

It is good to put this in because we are still using mediafield for a project and I am sure other clients are as well.

bradjones1’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new574 bytes

Here is is re-rolled. Marking RTBC...?

dave reid’s picture

Should we also be supporting 'property_callbacks' => array('entity_metadata_field_file_callback');?

dave reid’s picture

Status: Reviewed & tested by the community » Needs review
davidseth’s picture

Hi Dave,

The 'property_callbacks' => array('entity_metadata_field_file_callback') is necessary. If it is not in place then the field is hidden to Entity API.

with the callback in place I can confirm this works as that is what I have in my code and it is being used on 40k media nodes and all being indexed by search_api.

Cheers,

David

dave reid’s picture

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