Events¶
File Share dispatches a Drupal\file_share\Event\FileShareEvent for each of these. The constants are on Drupal\file_share\Event\FileShareEvents.
| Constant | When | The event carries |
|---|---|---|
CREATED |
A share is saved for the first time | The share |
RECIPIENT_ADDED |
Staff add a recipient, or a recipient invites someone | The share, who added them, the recipient ID |
RECIPIENT_REMOVED |
A recipient is removed, once for each invitee removed with them | The share, who removed them, the recipient ID |
SIGNED_IN |
Someone signs in with an emailed code or link | The share, when there is one, and the requester |
FILE_SERVED |
A file is served | The share, the requester, the recipient ID and the file |
REVOKED |
A share is revoked | The share and who revoked it |
use Drupal\file_share\Event\FileShareEvent;
use Drupal\file_share\Event\FileShareEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
final class FileShareSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents(): array {
return [FileShareEvents::FILE_SERVED => 'onServed'];
}
public function onServed(FileShareEvent $event): void {
// $event->share, $event->requester->email, $event->file.
}
}