public function beforeSave(Event $event, $entity, $options = [])
    {
        if ($this->_table->hasField($this->config('createdByField')) ||
            $this->_table->hasField($this->config('modifiedByField'))
        ) {
            $userId = $this->_getUserId();
            if ($userId > 0) {
                $entity->set($this->config('modifiedByField'), $userId);
                if ($entity->isNew()) {
                    $entity->set($this->config('createdByField'), $userId);
                }
            }
        }

        return true;
    }