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();
- Is myHelpers_Post.savePost correct?
- What else do I need to make this work?
- How do I test this properly? Can I use Craft::dd() inside the handler?