protected function getPWHashFunction(AbstractData $data, $passwordField, $saltField)
    {
        $that = $this;
        return function(Entity $entity) use ($data, $passwordField, $saltField, $that) {
            $password = $entity->get($passwordField);

            if (!$password) {
                return true;
            }

            $salt = $entity->get($saltField);
            $newSalt = $that->possibleGenSalt($salt, $entity, $saltField);

            $passwordHash = $this->encoder->encodePassword($password, $salt);

            $doGenerateHash = $that->doGenerateHash($data, $entity, $passwordField, $password, $newSalt);

            if ($doGenerateHash) {
                $entity->set($passwordField, $passwordHash);
            }
            return true;
        };
    }