Overwrite public function in

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:
PHP:
<?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/
 
In library/config.php add:
Code:
Proxy_Autoloader::proxyInstance();
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.
 
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.
 
Simples variants are not possible. This tool only for admins and developers. Not for end users and by plugins.
 
Top Bottom