public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options): void
    {
        if (! is_callable($this->getConfig('callback'))) {
            return;
        }

        $user = call_user_func($this->getConfig('callback'));
        if (empty($user['id'])) {
            return;
        }

        // Set created_by only if that field is not set during entity creation
        if ($entity->isNew() && empty($entity->get($this->getConfig('created_by')))) {
            $entity->set($this->getConfig('created_by'), $user['id']);
        }

        // Set modified_by if that field is not set during update
        $userId = $entity->isDirty($this->getConfig('modified_by')) && !empty($this->getConfig('modified_by')) ? $entity->get($this->getConfig('modified_by')) : $user['id'];
        $entity->set($this->getConfig('modified_by'), $userId);
    }