XF 2.2 Complete Event List

The even listener list in Admin CP seems very limited, where can I find the complete event listeners?

I want to find the most suitable event for checking uploads before they are saved, entity_pre_save works for me but it's too broad and is triggered too much.

Thanks for any help!
 
That is the full list.

You likely want to make use of the "event hint" to limit it to specific entities. So entity_pre_save with a hint of XF\Entity\Attachment would ensure it only fires when the attachment entity is at the pre-save stage.
 
I should note there are alternatives...

If you use entity_pre_save without a hint (can be useful if you're applying actions to multiple types of entity at a time) you can also check what the type of entity it is:

Code:
if ($entity instanceof \XF\Entity\Attachment || $entity instanceof \XF\Entity\SomeOtherEntity)
{
    // TODO: do stuff
}

You can use a class extension to extend the XF\Entity\Attachment (and other upload related) classes. There are a few exceptions, but you can pretty much monkey patch any class in XenForo using class extensions.
 
Thank you so much, Chris, your reply is super helpful. I didn't know how to use hint, now I changed the if statement to hint, it's neater.
 
Back
Top Bottom