At the moment we have the class SimplenewsSourceNode, with its own interface an load of code that actually works regardless of entity type. It would be better to have a SimplenewsSourceEntity class that worked for any entity and make SimplenewsSourceNode and extension of that.
I was trying to write a Source class for another entity (a commerce order) and found myself duplicating alot of the code in SimplenewsSourceNode. At the same time, extending SimplenewsSourceNode for a different entity felt wrong.
Comments
Comment #1
rlmumfordHere's a patch - currently it depends on #1890468: SimplenewsSourceCacheStatic hard coded to only accept node sources. so one of the patches here includes that change to ease testing.
Comment #2
rlmumfordHere's a re-run as the use of entity_view was a little wrong.
Comment #3
berdirLooks like a nice start. I guess there will be more changes required to actually support different entity types (e.g. the whole spool handling) but we can start with this and then partially convert the other things too.
Why is this moved?
docblock should at least be kept?
Hm. We only add those view modes to node. Note sure, we should probably at least document that they need to be created (e.g. with DS or a similar module) if another entity type should be used.
Missing spaces after some , (also for list())
As mentioned in the other issue, this actually needs to be updated as well, it currently does rely on something node (with this patch entity) specific.
So we need need to specify Entity here or change they way the cid is generated in there.
Comment #4
rlmumfordI agree, I think there will be some changes to make to the spool and also to some of the theme functions called by the Simplenews Source class.
I think I accidentally deleted it then put it back in. Should be fixed in this patch.
I think documentation is most important. I also thought about making a 'getViewMode($format)' method. This would allow one entity type to be rendered in different ways for different emails (e.g. an event entity may have a Confirmation source class associated with it and a Cancellation source class associated with it - two different source classes, one entity type, 6 (?) view modes; confirmation_(html/plain/textalt) and cancellation_(html/plain/textalt))
Fixed in patch.
I've added a fix in for this in the latest patch. I built the cid off of entity_type:entity_id:language and restricted the source parameter to being SimplenewsSourceEntityInterface. It sound like trying to tackle this and the other issue independently is going to cause more trouble than its worth, maybe just fix them both in here? This patch therefore includes some changes to the Cacheing classes and makes the other issue redundant.
Comment #5
berdirOk, committed and pushed.
The other issue can be closed as a duplicate now I think.