XF 2.0 Extending entity's getStructure vs code event listener

Jake B.

Well-known member
So I have a bunch of entities that I'm extending and also modifying the structure of them via the code event listener, I ended up trying to extend the getStructure method mostly out of curiosity and surprisingly it worked even though it is a static function, which has me wondering -- is this intentional and something that can be done reliably? Or is this only happening because of the way the class extension works in XF and it just happens to be running my class directly which is also calling parent::getStructure()? I haven't tested this, but I have a feeling if there was a class extension on the same class that ran before mine there would be issues with this so I've been sticking to using the event listener, but if I can do it in the extended class that'd be even better and would save on having my entity structure in a separate class than my entity data
 
There's never explicitly been an issue with extending static functions, so extending getStructure is fine.

Where possible we would usually recommend using a code event listener where a code event exists for something, but if you're extending the class anyway for other things (such as adding additional methods) then there's no harm either way.
 
Top Bottom