public function UserManager::getDrupalUserId in Social API 3.x
Same name and namespace in other branches
- 8.2 src/User/UserManager.php \Drupal\social_api\User\UserManager::getDrupalUserId()
Gets the Drupal user id based on the provider user id.
Parameters
string $provider_user_id: User's id on provider.
Return value
int|false The Drupal user id if it exists. False otherwise.
Overrides UserManagerInterface::getDrupalUserId
File
- src/
User/ UserManager.php, line 89
Class
- UserManager
- Manages database related tasks.
Namespace
Drupal\social_api\UserCode
public function getDrupalUserId($provider_user_id) {
try {
/** @var \Drupal\social_api\Entity\SocialApi[] $user */
$user = $this->entityTypeManager
->getStorage($this->entityType)
->loadByProperties([
'plugin_id' => $this->pluginId,
'provider_user_id' => $provider_user_id,
]);
if (!empty($user)) {
return current($user)
->getUserId();
}
} catch (\Exception $ex) {
$this->loggerFactory
->get($this
->getPluginId())
->error('Failed to to query entity. Exception: @message', [
'@message' => $ex
->getMessage(),
]);
}
return FALSE;
}