Calling a custom plugin method inside module #9823
-
But basically I am trying to call a plugin service method in another module's init() function, I hope that I'm doing something stupid here?: main Plugin file init() function: $this->setComponents([
'foo' => Foo::class,
]); Module file: use mynamespace\pluginhandle\PluginClass;
...
PluginClass::getInstance()->foo->bar() Get the error:
A helpful suggestion linked to this discussion which suggests maybe plugins aren't available at the point that modules load? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yep that’s the way to go, as plugins are loaded after modules. You will only need to worry about this trick for code in your module’s |
Beta Was this translation helpful? Give feedback.
Yep that’s the way to go, as plugins are loaded after modules. You will only need to worry about this trick for code in your module’s
init()
method (or called from it).