I have a g2 module that is registeringListners to GalleryEntity::save and GalleryEntity::delete.
These both listeners have been registered and only once.
However the handleEvent function is called twice for each Album saved by the user.
I am looking for any help to see that the function is called once per all events.
Thanks
Bharat.
Posts: 32509
what exact version of gallery 2 are you using? what core version?
and how did you register your event listener? (please post the code)
maybe reinstall your module.
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Posts: 11
Please fine the code pasted below.
Gallery version 2.2.3 (Latest download )
// from /modules/core/module.inc
$this->setRequiredCoreApi(array(7, 18));
$this->setRequiredModuleApi(array(3, 4));
// Constructor Code for Module
function UserActivityLogModule() {
global $gallery;
$this->setId('useractivitylog');
$this->setName($gallery->i18n('UserActivityLog'));
$this->setDescription($gallery->i18n('Provides useractivitylog about Gallery'));
$this->setVersion('0.9.0');
$this->setCallbacks('getSiteAdminViews');
$this->setCallbacks('registerEventListeners');
$this->setGroup('useractivitylog', $this->translate('User Activity Log'));
$this->setRequiredCoreApi(array(7, 18));
$this->setRequiredModuleApi(array(3, 4));
}
// Code for registering Listeners
function registerEventListeners() {
GalleryCoreApi::requireOnce('modules/useractivitylog/classes/UserActivityLogEvent.class');
$listener = new UserActivityLogEvent();
GalleryCoreApi::registerEventListener('GalleryEntity::save', $listener);
GalleryCoreApi::registerEventListener('GalleryEntity::delete', $listener);
GalleryCoreApi::registerEventListener('Gallery::Login', $listener);
}
Thanks for your time,
Deepak
Posts: 32509
> However the handleEvent function is called twice for each Album saved by the user.
- true, when adding a new album, there are two GalleryEntity::save events. one for the new album entity, and another for its parent album. we update the modification timestamp of an album when you add a sub-album or a sub-item.
- when editing an album, there's usually only one save event.
but... there's nothing that stops the framework to actually post 2 GalleryEntity::save events for the same entity for a single operation / action. some code could e.g. first create an entity, save it and then set some more properties/attributes on the entity and save it again.
but that's not the case in the above examples.
post edited 5 minutes after posting.
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Posts: 32509
in case you've read my initial response, i've edited my post shortly after posting it.
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Posts: 11
Thanks Valiant.
Thanks,
Deepak.