Hook for new log creation

I’m playing with the farm_withdrawal module.
Don’t know if I want to extend it, or just make someting different. I’m just exploring…

I want to let the veterinarian add his medical records directly in farmOS, and I’d like to send him an email copy of the log for his own recordkeeping.

I’ve implemented the mail logic, and log details are sendt on email upon log update.

Now I want to change it so the mail is sendt only on log creation.
My php/drupal knowledge is poor.

Out of the blue I tried to add CREATE but that throws errors
What is correct here?

public static function getSubscribedEvents() {
    return [
      LogEvent::PRESAVE => 'logPresave',
      LogEvent::UPDATE => 'logUpdate',
      LogEvent::CREATE => 'logCreate',
    ];
  }
2 Likes

Here is the Log module’s LogEvent class, which defines the available events:

There is no CREATE event, but there are INSERT, UPDATE, and PRESAVE events.

INSERT fires after a new log is saved.

UPDATE fires after an existing log is saved.

PRESAVE fires before a log is saved (regardless of whether it is new or existing).

3 Likes

Thanks. It worked.

2 Likes