Needs work
Project:
Model Entities
Version:
7.x-1.0-alpha1
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
16 May 2011 at 10:54 UTC
Updated:
21 Jul 2015 at 14:43 UTC
Jump to comment: Most recent
Since each entity type has an "entity class" defined, there is absolutely no reason to use any controller other than EntityAPIController.
You can specify defaults and buildContent in the entity class as well.
See my commerce_offer sandbox for an example (all the defaults are just class properties of the entity class).
After this is done you can remove the 'creation callback', as well as functions for creating, saving, deleting entities, and rely on the ones provided by Entity API (entity_create, entity_save, entity_delete)
Comments
Comment #1
ronald_istos commentedI see you point - probably right. I think there is some confusion between what the entity class itself and the entity controller should be doing and want to think about it a bit more.
Comment #2
bojanz commentedYes, it is still fuzzy. I made the changes to commerce_offer after talking with fago about it and us coming to the conclusion about the way of providing defaults (#1109828: Document how defaults for entity properties should be provided).
As for buildContent, that method can just be copied verbatim, and Entity API will be just as happy.
Comment #3
fagoYep, I'd suggest not overriding the controller class if possible. That way it could be exchanged easily, in theory. (e.g. to use another storage system).
Comment #4
awochna commentedI agree that it can make it more confusing. However, I can also see the value in showing newer people that you can override these things if necessary. I think that the documentation could be used to emphasize that you don't need overrides.
Comment #5
anybodyCould you perhaps create a patch to show us what's really needed and what is not?
The optional overrides might be added as comment? (to comment out like overrides in template.php?)