Problem/Motivation
From the wise mind of @Berdir at #2570593-165: Allow entities to be subclassed using "bundle classes":
One thought I had in to another issue would be to use this in forum.module for its special vocabulary and node type. That could be a big step to transform that module from a forgotten and ignored thing to a decent example and a real-word demonstration of this feature. Might also allow us to fix #2010132: Canonical taxonomy term link for forum vocabulary is broken although I'm still unsure about that feature, should probably use aliases instead
...
An early proof of concept might help to convince anyone who still doubts that this is useful though :)
To which @larowlan replied:
Great idea, forum is the ideal use case
Steps to reproduce
N/A
Proposed resolution
- Add a
ForumNode
bundle class. - Put stuff in there.
Remaining tasks
- Land #2570593: Allow entities to be subclassed using "bundle classes"
- Define a
ForumNode
class. - Register it with the entity system.
- Decide what to put in there.
- ...
User interface changes
Hopefully none.
API changes
TBD.
Data model changes
Nope.
Release notes snippet
TBD.
Comments
Comment #4
dwwComment #5
longwaveGreat idea! book.module also seems like an ideal candidate for this.
Comment #6
larowlanComment #8
AaronMcHaleBack when I maintained a site that used Forum, one of things we wanted was the ability for multiple content types to be able to be used for forum posts. The idea was that then some forums/containers could have posts with a different set of fields to other forums/containers. The way to achieve this ultimately was with one content type but using conditional fields module, it was a bit of a mess but it worked.
This issue got me thinking about that, and a Forum bundle class seems like a way forward for potentially supporting that scenario.
Comment #11
quietone CreditAttribution: quietone at PreviousNext commentedForum is approved for removal. See #1898812: [policy] Deprecate forum module for removal in Drupal 11
This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
It will be moved to the contributed extension once the Drupal 11 branch is open.
Comment #13
quietone CreditAttribution: quietone at PreviousNext commentedComment #14
BerdirFWIW, one thing to consider is backwards compatibility. If a custom site also defined a bundle class for the forum node type, then either this won't be used as it's overwritten, resulting in fatal errors/non-executed blocks of code if they check for an interface or so. Or the custom class is replaced, equally resulting in either fatal errors or code not being executed.
BC would be quite challenging to handle.
#8: Bundle classes are just a neat way to organize code, they don't allow to do something that can't be done otherwise as well. In this case, a setting to configure which node types could be used in forum. The only difference is where that setting is checked exactly, in node hook or so, or in the bundle info alter hook. In other words, not really related.