public function prePersist(LifecycleEventArgs $args): void
    {
        // Only act on invitation objects.
        $invitation = $args->getObject();
        if (!$invitation instanceof Invitation) {
            return;
        }

        // If the event author is the invitee accept the invitation.
        $event = $invitation->getEvent();
        if ($event->getAuthor() == $invitation->getInvitee()) {
            $invitation->setResponse(Invitation::RESPONSE_ACCEPT);
        }
    }