I believe you need something like this: $isPremium = XenForo_Application::autoload('EWRmedio_Model_Premium');
This will load a class if it exists and place true or false to the $isPremium variable if the class was successfully loaded or not respectively.
I believe you need something like this: $isPremium = XenForo_Application::autoload('EWRmedio_Model_Premium');
This will load a class if it exists and place true or false to the $isPremium variable if the class was successfully loaded or not respectively.
It will tell you if the class exists and is loadable, but it won't tell you if the class is a model or not.
For that, you need to do something like
PHP:
$isPremium=false;// check that the class exists and is loadableif(XenForo_Application::autoload('EWRmedio_Model_Premium')){// attempt to instantiate the model$model= @XenForo_Model::create('EWRmedio_Model_Premium');// check that the instantiated model is an extended XenForo_Model$isPremium=is_a($model,'XenForo_Model');}
If you don't want to instantiate your model and run it's constructor/deconstructor you can do this:
PHP:
$isPremium=false;// check that the class existsif(class_exists('EWRmedio_Model_Premium')){// create a reflection class to examine the class$reflection=newReflectionClass('EWRmedio_Model_Premium');// check if the class is an extended XenForo_Model$isPremium=$reflection->isSubclassOf('XenForo_Model');}
I think we need to use PHP features when programming on PHP class_exists('EWRmedio_Model_Premium') is shorter than XenForo_Application::autoload('EWRmedio_Model_Premium') and faster to type. Also, if these two really mean the same, it's better to use class_exists() because it makes your code independent on autoloader. I don't see why some classes in the framework should be autoloaded and others loaded manually. It doesn't make sense to me. Manual class loading is almost like require() we want to avoid. We should rely on PHP on loading our classes where needed.
When you call a class directly in XenForo, it will use the autoloader anyway - we simply catch the 'class not found' exception and attempt to rectify it with the autoloader.