1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Override core classes

Discussion in 'XenForo Development Discussions' started by Arty, Sep 21, 2012.

  1. Arty

    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?
     
  2. Naatan

    Naatan Well-Known Member

    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.
     

Share This Page