xf_phantom
Well-known member
1. thx again again again for the resolvedynamic usage
2. to avoid to have to write always the same 10 lines of code, wouldn't it be worth to include a new method to XenForo_Application doing something like:
Just in case we want to do it the proper way and not just
$class = XenForo_Application::resolveDynamicClass($class);
$obj = new $class;
2. to avoid to have to write always the same 10 lines of code, wouldn't it be worth to include a new method to XenForo_Application doing something like:
PHP:
public static function getDynamicClassInstance($class, $instanceTypeValidation=null){
$class = XenForo_Application::resolveDynamicClass($class);
if (XenForo_Application::autoload($class))
{
$obj = new $class;
if ($instanceTypeValidation){
if ($obj instanceof $instanceTypeValidation){
return $obj;
}
else {
throw new XenForo_Exception("$class isn't a instance of $instanceTypeValidation");
}
}
return $obj;
}
throw new XenForo_Exception("$class doesn't exist");
}
Just in case we want to do it the proper way and not just
$class = XenForo_Application::resolveDynamicClass($class);
$obj = new $class;
Last edited:
Upvote
1