Skip to content

Instantly share code, notes, and snippets.

@StanAngeloff
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StanAngeloff/f83b91f2f39e7b1ad427 to your computer and use it in GitHub Desktop.
Save StanAngeloff/f83b91f2f39e7b1ad427 to your computer and use it in GitHub Desktop.
<?php
// [..snip..]
$this->participantRepositoryFactory
->forTenant(
$this->getTenantIdFromOAuthClient($client)
)
->persist(
$participant
);
// [..snip..]
/**
* Get a TenantId instance from an authenticated OAuth client.
*
* @param OAuthClient $client
*
* @return TenantId
*/
private function getTenantIdFromOAuthClient(OAuthClient $client)
{
$tenantId = $client->getValueOfRelation(OAuthClient::RELATION_SECURITY_USER);
if ($tenantId === null) {
throw new RuntimeException(
strtr(
'Cannot find a "{relation}" relation for OAuth client "{name}".',
array(
'{relation}' => OAuthClient::RELATION_SECURITY_USER,
'{name}' => $client->getName(),
)
),
1426678183
);
}
return new TenantId($tenantId);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment