/** * Constructor. * * @param string $guid * @param string $providerName * @param AccessToken $accessToken * @param ResourceOwnerInterface $resourceOwner */ public function __construct($guid, $providerName, AccessToken $accessToken, ResourceOwnerInterface $resourceOwner) { if (Uuid::isValid($guid) === false) { throw new \RuntimeException('Tried to create Transition object with an invalid GUID.'); } $this->guid = $guid; $this->accessToken = $accessToken; $this->resourceOwner = $resourceOwner; $providerEntity = new Entity\Provider(); $providerEntity->setProvider($providerName); $providerEntity->setRefreshToken($accessToken->getRefreshToken()); $providerEntity->setResourceOwnerId($resourceOwner->getId()); $providerEntity->setResourceOwner($resourceOwner); $this->providerEntity = $providerEntity; }
/** * Create a new provider entity object. * * @param AccessToken $accessToken * @param ResourceOwnerInterface $resourceOwner */ protected function createProviderTransition(AccessToken $accessToken, ResourceOwnerInterface $resourceOwner) { // Create a new provider entry $providerName = $this->providerManager->getProviderName(); // If we have an authorisation, this is for an existing and logged in account, // else we either have a new registration or one we need to find an associate. $guid = $this->session->getAuthorisation()->getGuid(); $transition = new Transition($guid, $providerName, $accessToken, $resourceOwner); $this->session->addAccessToken($providerName, $accessToken)->setTransitionalProvider($transition); $this->setDebugMessage(sprintf('Creating provider profile for %s ID %s', $providerName, $resourceOwner->getId())); $this->setDebugMessage(sprintf('Creating provisional %s provider entity for access token %s for ID %s', $providerName, $accessToken, $resourceOwner->getId())); }