I have a component ('com_foo') which has a model called 'foobar'. The class declaration is like this:
class FooModelbar extends JModelItem
This class has a public method called getFooBar().
I also have a system plugin called 'foobar'. I am trying to access the public method of the component from this plugin.
JLoader::register('FooModelBar', JPATH_SITE . '/components/com_foo/models/bar.php'); $foobarInstance = new FooModelBar(); $baz = $foobarInstance->getFoobar();
But I am getting some unrelated errors like 'Cannot redeclare function x' which is not even in the plugin or the component. And if I turn off the plugin or remove the JLoader::register line of code, the error disappears. So clearly I must be doing something wrong.
What is the 'correct' way to access a component's method from a system plugin?