When using Craft Event triggers in PHP (e.g. Event::on
), is there any event metadata that can tell where the event originated from? E.g. if it was triggered from an admin action, or if it was triggered by module code (e.g. saveElement
)?
Perhaps something in the $event
object?
Event::on(
Entry::class,
Entry::EVENT_BEFORE_SAVE,
function(ModelEvent $event) {
$entry = $event->sender;
Thanks!
EVENT_BEFORE_SAVE
, so we were considering usingsaveElement
andEVENT_AFTER_SAVE
, but, as expected, had an infinite loop of saving. Was exploring all options, including being able to tell difference between save type. However, looks like we will abandon this approach for reasons you indicate. Thanks for reply :)