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.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | mediafield-entityapi-1321600-12.patch | 574 bytes | bradjones1 |
| #4 | patch-mediafield-1321600-4.patch | 562 bytes | bradjones1 |
Comments
Comment #1
dave reidMedia 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.
Comment #2
bradjones1Hi 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.
Comment #3
bradjones1Edit: It looks like the work needs to happen at #1303428: Rules support for file_entity
Postponing, pending successful fix over at file_entity.
Comment #4
bradjones1I'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 aproperty_typedefinition. 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.
Comment #5
sunComment #6
dave reidI don't use Rules so it would be good to get some confirmation from others that this is the appropriate solution.
Comment #7
agentrickardGiven 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.
Comment #8
dave reidComment #9
bradjones1Re: #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.
Comment #10
dave reidI'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.
Comment #11
davidseth commentedI would still add the code, but use
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.
Comment #12
bradjones1Here is is re-rolled. Marking RTBC...?
Comment #13
dave reidShould we also be supporting
'property_callbacks' => array('entity_metadata_field_file_callback');?Comment #14
dave reidComment #15
davidseth commentedHi 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
Comment #16
dave reidGreat committed the patch essentially from #1404720: Integrate Mediafield submodule with Entity Framework to both 7.x-2.x and 7.x-1.x.
http://drupalcode.org/project/media.git/commit/d8713a7
http://drupalcode.org/project/media.git/commit/e6b462f