Service will return the user ID of given username.

@param string $username

@return int
340504
public function getIdFromUsername($username)
    {
        $id = $this->load('uname2uid', $username);

        return ($id === 0) ? null : (int) $id;
    }
862819
public function get($username) {


        if(is_numeric($username)) {
            $key = 'id';
        }
        else {
            $key = 'username';
        }

        $query = sprintf(self::SELECT_ALL,
            $this->params['table'],
            $this->params[$key],
            $this->pdo->quote($username));

        $stmt = $this->pdo->query($query);

		if(!$stmt) {
			$error = $this->pdo->errorInfo();
			
			throw new \Exception($error[2]);
		}
		
        if($user = $stmt->fetch(PDO::FETCH_ASSOC)) {
            return $user;
        }
        else {
            throw new UserException('User not found', 404);
        }
    }
553222
public function getUserId()
    {
        if (null === $this->userId && null !== $this->user) {
            $this->userId = $this->user->id;
        }

        return $this->userId;
    }
1370608
public function getPeopleIdFromFullName($fullName) {
        $result = DB::table('peoples')
            ->where('first_name',  $this->getFirstName($fullName))
            ->where('middle_name', $this->getMiddleName($fullName))
            ->where('surname',     $this->getLastName($fullName))
            ->first()
        ;

        if (count($result) > 0) {
            return $result->id;
        }
        return 0;
    }
888023
protected function _getUserId(): ?string
    {
        $userId = null;
        $callback = $this->config('userIdCallback');
        if (is_callable($callback)) {
            $userId = $callback();
        }

        return $userId;
    }
254649
public function findUserByUsername($username)
    {
        $qb = $this->createQueryBuilder('user')
            ->where('user.username=:username');

        $query = $qb->getQuery();
        $query->setParameter('username', $username);

        return $query->getSingleResult();
    }
887279
public function loadUserByUsername($username)
    {
        if ($username !== 'testUsername') {
            return false;
        }

        /** @var UserInterface $user */
        $user = new \stdClass();
        $user->id = 123;
        $user->username = $username;
        $user->firstName = 'aName';
        $user->lastName = 'aSurname';

        return $user;
    }
413416
public static function isExistByUsername( $username ) {

		$user = self::find()->where( 'username=:username', [ ':username' => $username ] )->one();

		return isset( $user );
	}
515027
public function getIdByUsername($username, array $params = [])
    {
        $arr = $this->listing(false, $params);
        if (!isset($arr[$username])) {
            return false;
        }

        return $arr[(string) $username];
    }
863557
public function usernameExists($userName)
    {
        $existing = $this->em->getRepository(User::class)->findOneBy(
            [
                'username' => $userName,
            ]
        );

        return (bool) $existing;
    }
1259438
public function getUserID()
    {
        if (isset($this->userID)) {
            return (int) $this->userID;
        }

        return (int) $this->kontakt->getMyKey();
    }
1143270
function getCounterKey($username)
    {
        $k = $this->app['config']->get('cache.namespace');
        $k .= ':failed_login_counter.';
        $k .= $username;

        return $k;
    }
1368249
public function find($username)
    {
        $parameters['username'] = $username;
        return $this->apiClient->callEndpoint(self::ENDPOINT, $parameters);
    }
766810
public static function findByUsername($username)
    {
        foreach (self::$users as $user) {
            if (strcasecmp($user['username'], $username) === 0) {
                return new static($user);
            }
        }

        return null;
    }
119219
public function loadUserByUsername($username)
    {
        if (!isset($this->cachedUsers[$username])) {
            $this->cachedUsers[$username] = $this->userProvider->loadUserByUsername($username);
        }
        return $this->cachedUsers[$username];
    }
42116
public function getIdByUserName($userName)
    {
        $shopId = Registry::getConfig()->getShopId();
        $userId = DatabaseProvider::getDb()
            ->getOne(
                'SELECT `OXID` FROM `oxuser` WHERE `OXUSERNAME` = ? AND `OXSHOPID` = ?',
                [
                    $userName,
                    $shopId
                ]
            );

        return $userId;
    }
1236756
protected static function getEmailByUsername($username)
    {
        if (empty($username)) {
            throw new BadRequestException("Missing required username.");
        }

        /** @var User $user */
        $user = User::whereUsername($username)->get(['email'])->first();

        if (empty($user)) {
            throw new NotFoundException('The supplied username was not found in the system.');
        }

        return $user->email;
    }