XF 2.3 Traits in XenForo

Marcus

Well-known member
I enjoy programming for XenForo and noticed there are few Traits used. Traits are spectacular for easy integration of new functionality that is used just for that one addon. To reduce redundancy in the Controller I use Traits. Is there a build-in alternative in XenForo for this that works a bit better or is better integrated with XenForo? And what would you use in Event Listener to reduce redundancy? Are XenForos Services a bit like a Trait, so that you call them up also in other areas than the Controllers?

As I got into the programming I try to leave XenForo as untouched as possible to make the addon more future-proof and less invasive. So I want to use the XenForo way of coding as much as possible.
 
Controller Plugins sort of act like traits for shared behavior in controllers, and Entity Behaviors allow for shared behavior on saving and deleting. For other uses you can just use traits.
 
Top Bottom