Override core classes

Arty

Well-known member
Is it possible to override some functions in core classes that don't have event listeners?

For example, I want to alter behavior of XenForo_Session::startPublicSession() and XenForo_Link::buildPublicLink(). Is it possible to do without editing library/XenForo/ files?
 
It's not facilitated by XenForo.

You could do this by retrieving the contents of relevant files programmatically, injecting your class dependencies and eval-ing the resulting code, but this is by no means optimal and generally the use of eval() is frowned upon.

A better way might be to copy those classes altogether, then modify them and include them manually from your index.php or config.php. This circumvents the autoloader as the classes are loaded manually from your location. Problem with this is you can't redistribute XenForo's code and it's probably not backwards compatible.

The only real solution here is getting the devs to implement support for extending these classes. But I don't see that happening any time soon.
 
Back
Top Bottom