Calling a method from a service in another plugin from an event I'm having a problem calling a service method from another plugin when hooking into the beforeSend event in the ContactForm plugin. I have the code below in a super simple plugin called ContactFormExtra to catch if someone wants to also subscribe to our newsletter when they fill in the contact form. I have another subscribe plugin setup with it's service class having the methods to do the subscribing - which also handles a simpler subscribe form without the contact form fields. Any ideas on how this could work - or do I need to put all the subscribe stuff again into the ContactFormExtra plugin?

This follows the example on GitHub for pixelandtonic/ContactForm

When trying to subscribe on the contact form, I get this error:

Craft\ContactFormExtraPlugin and its behaviors do not have a method or closure named "_getSettings". 


Looks like it's trying to call the Subscribe plugin's functions from the ContactFormExtra plugin?

If I don't choose to subscribe and submit the form, then the Subscribe plugin service call is skipped, moving on to the calls on the ContactFormExtra plugin's service. Then I get this error:

Property "Craft\WebApp.contactformextra" is not defined.


Simple ContactFormExtra plugin code: 
(plugins/contactformextra/ContactFormExtraPlugin.php)

class ContactFormExtraPlugin extends BasePlugin
{
  public function init()
  {
    craft()-&gt;on('contactForm.beforeSend', function(ContactFormEvent $event) {
      $message = $event-&gt;params['message'];
      $subscribe = craft()-&gt;request-&gt;getPost('subscribe');
      $attribs = $message-&gt;getAttributes();
      if ($subscribe == 1) {
        $result = SubscribeService::subscribe($attribs['fromEmail']);
      }
      // save the record
      $attribs = $message-&gt;getAttributes();
      $attribs['subscribe'] = $subscribe;
      $enquiryModel = craft()-&gt;contactformextra-&gt;newEnquiry($attribs);
      craft()-&gt;contactformextra-&gt;saveEnquiry($enquiryModel);
    });
  }
  ...
}


ContactFormExtra plugin service code: 
(plugins/contactformextra/services/ContactFormExtraService.php)

class ContactFormExtraService extends BaseApplicationComponent
{

    public function newEnquiry($attributes) {
      // do stuff here
    }

    public function saveEnquiry(ContactFormExtra_EnquiryModel &amp;$model) {
      // do stuff here
    }

}


Subscriber plugin:
(plugins/subscribe/services/SubscribeService.php)

class SubscribeService extends BaseApplicationComponent
{
  protected $settings;

  private function _getSettings()
  {
    $plugin_settings = craft()-&gt;plugins-&gt;getPlugin('subscribe')-&gt;getSettings();
    $this-&gt;settings = $plugin_settings;
  }

  public function subscribe($email)
  {
    $this-&gt;_getSettings();
    // do the subscribing here...
  }

}
Capitalization matters when you're calling services. Try updating this line:

$enquiryModel = craft()-&gt;contactformextra-&gt;newEnquiry($attribs);

to this:

$enquiryModel = craft()-&gt;contactFormExtra-&gt;newEnquiry($attribs);

and make sure you update that across all the places where you're calling that service. Try that, and post the results. I'll take another look if you're still seeing the issue, which may still be there; just grabbing at low-hanging fruit right now. :)