/**
* Returns a Model object, always creating it
*
* @param string $type The model type to instantiate
* @param string $prefix Prefix for the model class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return self|boolean A \JModelLegacy instance or false on failure
*
* @since 3.0
* @deprecated 5.0 Get the model through the MVCFactory instead
*/
public static function getInstance($type, $prefix = '', $config = array())
{
@trigger_error(sprintf('%1$s::getInstance() is deprecated. Load it through the MVC factory.', self::class), E_USER_DEPRECATED);
$type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
if ($model = self::createModelFromComponent($type, $prefix, $config)) {
return $model;
}
$modelClass = $prefix . ucfirst($type);
if (!class_exists($modelClass)) {
$path = Path::find(self::addIncludePath(null, $prefix), self::_createFileName('model', array('name' => $type)));
if (!$path) {
$path = Path::find(self::addIncludePath(null, ''), self::_createFileName('model', array('name' => $type)));
}
if (!$path) {
return false;
}
require_once $path;
if (!class_exists($modelClass)) {
Log::add(Text::sprintf('JLIB_APPLICATION_ERROR_MODELCLASS_NOT_FOUND', $modelClass), Log::WARNING, 'jerror');
return false;
}
}
return new $modelClass($config);
}