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

renderHtml in fakeBase classes

Dan

Well-known member
#1
What's the best way to not break other addons, extending the same fake View Baseclass?

I've found this workaround, is there any better way?
PHP:
foreach(class_parents($this) as $parent)
{
if(method_exists($parent,'renderHtml')){
parent::renderHtml();
break;
}
}
 
//my code...
 

Jeremy

Well-known member
#2
What's the best way to not break other addons, extending the same fake View Baseclass?

I've found this workaround, is there any better way?
PHP:
foreach(class_parents($this) as $parent)
{
if(method_exists($parent,'renderHtml')){
parent::renderHtml();
break;
}
}
 
//my code...
Unless using default XenForo view classes, you should realistically be defining your own MyAdd_View_Base, etc. I also believe XFCP also works for View classes.
 

Dan

Well-known member
#3
Unless using default XenForo view classes, you should realistically be defining your own MyAdd_View_Base, etc. I also believe XFCP also works for View classes.
It is for a XenForo View Class and i'm using XFCP.


Let's take XenForo_ControllerPublic_Warning::actionIndex as example
It's using the view XenForo_ViewPublic_Warning_Info which doesn't exist.

That's why i created my own View implementing parent::renderHtml and extending from XenForo_ViewPublic_Warning_Info via the XenForo Proxyclass System.
It's working fine.

If there would be now another addon, which is also extending from XenForo_ViewPublic_Warning_Info and implementing renderHtml one of the both wouldn't run because you can't just run parent::renderHtml() because there's no parent method in the fake class, so you NEED to run it, but if only 1 addon is installed, you'll get an fatal error because parent::renderHtml isn't declared.