renderHtml in fakeBase classes

Dan

Well-known member
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...
 
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.
 
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.
 
Top Bottom