1

I have some questions about events. I want to fire a custom event from another plugin. The event handler is in MyHelpers_PostService.php (plugin A).

public function onSavePost(Event $event)
{
    $this->raiseEvent('onSavePost', $event);
}

My init() method (plugin B):

public function init()
{
    craft()->on('myHelpers_Post.savePost', function(Event $event)
    {
       // delete a cache key 
       craft()->pluginB->clearCache('forum-home-desktop');
    });
}

This is my first time working on Craft events, so please bear with me. I tested this by saving a new Helpers Post on the front-end and nothing happens.

The clearCache() method is just using Craft's deleteCachesByKey();

  1. Is myHelpers_Post.savePost correct?
  2. What else do I need to make this work?
  3. How do I test this properly? Can I use Craft::dd() inside the handler?
1

myHelpers_Post.savePost was wrong. It should have been myHelpers_post.savePost. It's okay to delete this question.

  • It's good to keep the question in, in case someone else comes across a similar problem. Just accept your own answer as the correct one! – KSP Aug 6 '17 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.