I wanted to listen to the onSetStatus
event of the SetStatusElementAction
and used the same code like in the EntryElementType
class:
$setStatusAction = craft()->elements->getAction('SetStatus');
$setStatusAction->onSetStatus = function(Event $event) {
MyPlugin::log('maybe');
}
But it didn't work and I had to hack into the core making following code changes:
in the ElementsService
class:
/**
* Fires an 'onSetStatus' event.
*
* @param Event $event
*
* @return null
*/
public function onSetStatus(Event $event)
{
$this->raiseEvent('onSetStatus', $event);
}
in the EntryElementType::getAvailableActions
method where the onSetStatus
is called:
craft()->elements->onSetStatus($event);
This way I'm able to listen to the event in my plugin:
craft()->on('elements.setStatus', function() { ... });
The problem is that with the next update I have to do the code changes again. Is there a better way to listen to the event or is this worth a push request?
elements.onPerformAction
andelements.onBeforePerformAction
events