public getAccount ( Platformsh\Client\Model\ProjectAccess $user, boolean $reset = false ) : array | ||
$user | Platformsh\Client\Model\ProjectAccess | |
$reset | boolean | |
Результат | array | An array containing 'email' and 'display_name'. |
public function getAccount(ProjectAccess $user, $reset = false)
{
$cacheKey = 'account:' . $user->id;
if ($reset || !($details = self::$cache->fetch($cacheKey))) {
$details = $user->getAccount()->getProperties();
self::$cache->save($cacheKey, $details, $this->config->get('api.users_ttl'));
}
return $details;
}
/** * Get a list of user email addresses. * * @return string[] */ public function getUserEmails() { $project = $this->getProject(); if (!$project) { return []; } $emails = []; foreach ($project->getUsers() as $user) { $account = $this->api->getAccount($user); $emails[] = $account['email']; } return $emails; }