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

Overwrite public function in

Discussion in 'XenForo Development Discussions' started by Marcus, Feb 21, 2012.

  1. Marcus

    Marcus Well-Known Member

    To overwrite private function protected static function _getDefaultAvatarUrl() my plan is to overwrite the public function public static function getAvatarUrl() that uses the private one exclusively.*

    How could I overwrite the public function? My addon listens on load_class_model and once the class is XenForo_Template_Helper_Core where the public function is located I extend that to my personal Core.php:
    class MyAddon_Core extends XFCP_MyAddon_Core
    public static function getAvatarUrl(array $user$size$forceType '')
    {  return 
    ''; }
    I want to disable all avatars with this test, however everything works as usual. Any ideas?

    (* with the exception of gravatar functionality I disabled)

    Similar thread: http://xenforo.com/community/thread...-class-and-override-protected-function.25889/
  2. infis

    infis Well-Known Member

  3. infis

    infis Well-Known Member

    In library/config.php add:
    After need copy library/XenForo/Template/Helper/Core.php to library/Proxy/XenForo/Template/Helper/Core.php and change code as you want. In runtime will be used class from proxy.
    It work without extending original class.
  4. Marcus

    Marcus Well-Known Member

    This is a great idea. However I want to make the changes as small as possible. The class Core.php is rather huge and I would very much prefer to only manipulate what I really have to change.
  5. infis

    infis Well-Known Member

    Simples variants are not possible. This tool only for admins and developers. Not for end users and by plugins.

Share This Page