You are here

public function Authmap::getAll in External Authentication 8

Same name and namespace in other branches
  1. 2.0.x src/Authmap.php \Drupal\externalauth\Authmap::getAll()

Get all external authnames for a given user ID.

Parameters

int $uid: The Drupal user ID.

Return value

array An array of external authnames / IDs for the given user ID, keyed by provider name.

Overrides AuthmapInterface::getAll

File

src/Authmap.php, line 90

Class

Authmap
Class Authmap.

Namespace

Drupal\externalauth

Code

public function getAll($uid) {
  $query = $this->connection
    ->select('authmap', 'am')
    ->fields('am', [
    'provider',
    'authname',
  ])
    ->condition('uid', $uid)
    ->orderBy('provider', 'ASC')
    ->execute();
  $result = $query
    ->fetchAllAssoc('provider');
  if ($result) {
    foreach ($result as $provider => $data) {
      $result[$provider] = $data->authname;
    }
  }
  return $result;
}