The file_entity should implement hook_entity_property_info_alter to provide metadata about the added type property.

This is needed, for instance, to allow the Search API to index allow filtering on file types (cf. #1196622: Indexing (and searching) a File Entity file type).

Comments

pbuyle’s picture

Status: Active » Needs review
StatusFileSize
new2.11 KB
drunken monkey’s picture

Category: support » feature

Patch looks good, as far as I can see. Didn't test it, though.

mikedillion’s picture

dave reid’s picture

Component: Code » File entity
dave reid’s picture

Project: D7 Media » File Entity (fieldable files)
Component: File entity » Code
aaron’s picture

Status: Needs review » Needs work

The last submitted patch, file_entity_entity_property_info_alter-1197450-1.patch, failed testing.

aaron’s picture

Status: Needs work » Needs review
StatusFileSize
new1.58 KB

here's a reroll. i'm not certain how to review it, since it's using the entity api hook and search api module, and i'm not too familiar with either module.

dave reid’s picture

Status: Needs review » Needs work

This should be re-rolled to use the new file_type_get_names() function. Also, does entity.module implement hook_hook_info() so that this hook can go in file_entity.entity.inc?

drunken monkey’s picture

Also, does entity.module implement hook_hook_info() so that this hook can go in file_entity.entity.inc?

It does implement the hook, but seemingly only for hook_entity_property_info(), not for the corresponding alter hook. Seems like a case for an Entity API issue.

dave reid’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

File entity has switched to a 7.x-2.x branch and the 7.x-1.x branch is no longer used. Please make sure to update your Git clones.

dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new794 bytes

Another re-roll based on the current code.

dave reid’s picture

Includes support for the creation and form callbacks too.

dave reid’s picture

I'm not 100% sure on just using entity_metadata_create_object for the creation callback.

dave reid’s picture

Ok, the only thing I was uncertain about was if the create callback needs to support adding in the file mime type, but because file_entity_file_presave() does that automatically, I'm confident about putting this in as-is.

Status: Needs review » Needs work

The last submitted patch, 1197450-file-type-entity-property-info.patch, failed testing.

dave reid’s picture

Status: Needs work » Fixed

Pushed #15 to Git. http://drupalcode.org/project/file_entity.git/commit/372ce37

My apologies to mongolito404 and aaron - in my rush to commit this, I forgot to give you mention in the commit message. :(

Status: Fixed » Closed (fixed)

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