XF 2.0 Is using the entity_structure code event optional?

Jon W

Well-known member
I notice in the resource standards it says:
20. Where a specific code event exists, a listener should be created to utilise it rather than a full class extension.

However, I noticed in this thread, nobody seemed to object to the fact that @AndyB was extending the class.

Whenever I've spotted this in our add-ons, I've been trying to make sure that we keep to the rules. Am I being too legalistic?
 
The general rule of thumb is that if the wording states "should" then it should be a very best effort, kind of thing. If the wording states "must" then, well... you better do it ;)

In this particular case, if you are already extending the relevant entity class (which is really not uncommon if you're changing the structure) then it's fine to not bother with the individual listeners. So, if you already need to modify the class to add new methods, you might as well extend the existing methods for things like the structure and pre/post stuff.
 
That makes a lot of sense given that the overhead is probably slightly higher when extending a class than using a code event.
 
Back
Top Bottom