Proper way to add functions to XenForo_Model_Import

Deek

Member
I'm currently working on my own custom importer for Vanilla forums. I've created the listener for my class
PHP:
class TheCollectiveMind_Importer_Vanilla extends XenForo_Importer_Abstract
and its going well so far but I need to make a custom methods that aren't in XenForo_Model_Import

I want to be able to call these functions on my model declared by
PHP:
$model = $this->_importModel
then called in my TheCollectiveMind_Importer_Vanilla by
PHP:
$model->getUserNameByEmail($this->_convertToUtf8($thread['Email']))

What is the proper method of extending XenForo_Model_Import so I'm able to do this?

For refrence here is the function I need to be able use.
PHP:
public function getUserNameByEmail($email)
{
return $this->_getDb()->fetchOne('
    SELECT username
    FROM xf_user
    WHERE email = ?
    ', $email);
}
 
You can dynamically extend the model using the load_class_model event.
 
I created a listener for load_class_model event and here is the class I created
PHP:
class TheCollectiveMind_Listener_Importer_Vanilla
{
    public static function loadClassModel($class, array &$extend)
    {
        if($class == 'XenForo_Model_Import')
        {
            extend[] = 'TheCollectiveMind_Model_Import_Vanilla';
            extend[] = 'TheCollectiveMind_Model_Import';
        }
    }
}

But then I get the error
Code:
Fatal error: Call to undefined method TheCollectiveMind_Model_Import::getImporter() in <path>/library/XenForo/ControllerAdmin/Import.php on line 104

The importer I created works fine but once I added extend[] = 'TheCollectiveMind_Model_Import'; that's when the problems happened.

Is this the wrong way to simply add a function (or two) into the base Import Model?
 
Top Bottom