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).

Files: 
CommentFileSizeAuthor
#15 1197450-file-type-entity-property-info.patch1.73 KBDave Reid
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1197450-file-type-entity-property-info_1.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#13 1197450-file-type-entity-property-info.patch1.73 KBDave Reid
PASSED: [[SimpleTest]]: [MySQL] 17 pass(es).
[ View ]
#12 1197450-file-type-entity-property-info.patch794 bytesDave Reid
PASSED: [[SimpleTest]]: [MySQL] 17 pass(es).
[ View ]
#8 file_entity_entity_property_info_alter-1197450-8.patch1.58 KBaaron
PASSED: [[SimpleTest]]: [MySQL] 35,800 pass(es).
[ View ]
#1 file_entity_entity_property_info_alter-1197450-1.patch2.11 KBpbuyle
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch file_entity_entity_property_info_alter-1197450-1.patch.
[ View ]

Comments

pbuyle’s picture

Status:Active» Needs review
StatusFileSize
new2.11 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch file_entity_entity_property_info_alter-1197450-1.patch.
[ View ]
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: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
PASSED: [[SimpleTest]]: [MySQL] 35,800 pass(es).
[ View ]

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
PASSED: [[SimpleTest]]: [MySQL] 17 pass(es).
[ View ]

Another re-roll based on the current code.

Dave Reid’s picture

StatusFileSize
new1.73 KB
PASSED: [[SimpleTest]]: [MySQL] 17 pass(es).
[ View ]

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

StatusFileSize
new1.73 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1197450-file-type-entity-property-info_1.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

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.