Welcome Guest, Not a member yet? Register   Sign In
Loading a plugin within a library
#1

[eluser]oste15[/eluser]
I was wondering if it is possible to load a plugin inside of a library file.

When I try to load my custom plugin inside my custom library I get the following error
Fatal error: Call to a member function plugin()

I also get this warning
Message: Undefined property: ApiCall::$load

The only solution I see is to autoload the plugin, but that is not the best solution.
#2

[eluser]WanWizard[/eluser]
First of all, don't use plugins. They are deprecated and will no longer be supported in CI 2.0. Use a helper instead (they're the same thing anyway)

How do you load your library? It looks like $this->load doesn't work in your library, so the plugin is not loaded, and therefore the call to the plugin fails.

$this->load doesn't work in constructors, so use
Code:
$CI =& get_instance();
$CI->load->plugin('plugin');
#3

[eluser]oste15[/eluser]
Thanks, gotta remember about the old get_instance reference.

It is also interesting to note that the plugins are being deprecated. Like you mentioned there is really no difference between plugins and helpers. The user guide mentions that helpers should not be OO, but that is silly and is obviously being changed.

Thanks again.




Theme © iAndrew 2016 - Forum software by © MyBB