I have G2 User Activity Log module that is installing good.
However, I am trying to registerListeners() and writing a handler(). The code I have
written for the purpose is below and it is not doing anything.
in module.inc :
function registerEventListeners() {
GalleryCoreApi::requireOnce('modules/useractivitylog/classes/UserActivityLogHelper.class');
$listener = new UserActivityLogHelper();
GalleryCoreApi::registerEventListener('GalleryEntity::save', $listener);
GalleryCoreApi::registerEventListener('GalleryEntity::delete', $listener);
}
in classes/UserActivityLogHelper.class :
function handleEvent($event) {
$valid_event = false;
if ($event->getEventName() == 'GalleryEntity::save') {
$entity = $event->getEntity();
if ($entity->getEntityType() == 'GalleryAlbumItem') {
// do something when user saves album
}
}
return array(null, null);
}
I think my handler is not even getting called in any event and definitely not when I
add an album.
Thanks,
Deepak
Posts: 32509
- don't forget to declare your registerEventListener method in the module constructor
$this->setCallbacks('registerEventListeners');
- reinstall the module
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Posts: 11
Thanks that certainly did the job.
Posts: 25
I know this post is a bit old but I found it looking for examples on how to use the registerEventListeners and this is a great example of how to do it.
Of course this will change in 2.3 as it will no longer be used. Later I will post an example of how to use the new way to listen to events.