Calling action from main class init() I'm trying to call an action from my main class in Craft 3. This is working fine with my services like this:

AbandonedCart::$plugin-&gt;serviceExample-&gt;serviceMethod();


I've tried to do something similar for my action but it doesn't work and I can't find any solution to it.

AbandonedCart::$plugin-&gt;actionExample-&gt;actionFunction();


Any ideas on how to do this?

Thanks in advance,
Sam
You need to call your setComponents function before you are trying to access your components otherwise - logically - they are not defined

public function init()
{
    parent::init();
    self::$plugin = $this;

    // define the components / services
    $this-&gt;setComponents(
        [
            'serviceExample' =&gt; ServiceExample::class
        ];
    );

    // access them
    $this-&gt;serviceExample-&gt;serviceMethod();
    // if it's easier for you to remember you can as well use the longer/slower syntax
    AbandonedCart::$plugin-&gt;serviceExample-&gt;serviceMethod();
);