Last active
August 29, 2015 14:17
-
-
Save StanAngeloff/f83b91f2f39e7b1ad427 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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