Sulu\Bundle\SecurityBundle\Entity\UserRepository::getUsernameByApiKey PHP Method

getUsernameByApiKey() public method

returns username for given apiKey.
public getUsernameByApiKey ( string $apiKey ) : string
$apiKey string userId
return string
    public function getUsernameByApiKey($apiKey)
    {
        $user = $this->findOneBy(['apiKey' => $apiKey]);
        if (!$user) {
            return;
        }
        return $user->getUsername();
    }