本文整理汇总了PHP中App\Model\User::getProviderAccessToken方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getProviderAccessToken方法的具体用法?PHP User::getProviderAccessToken怎么用?PHP User::getProviderAccessToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Model\User
的用法示例。
在下文中一共展示了User::getProviderAccessToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: discover
/**
* {@inheritDoc}
*/
public function discover(User $user)
{
$client = clone $this->client;
$client->setDefaultOption('headers/Authorization', 'token ' . $user->getProviderAccessToken('github'));
$request = $client->get('/user/orgs');
$response = $request->send();
$data = $response->json();
$orgRequests = [$client->get('/user/repos')];
foreach ($data as $org) {
$this->logger->debug(sprintf('adding "' . $org['repos_url'] . '" for crawl'));
$orgRequests[] = $client->get($org['repos_url']);
}
$orgResponses = $client->send($orgRequests);
$composerRequests = [];
foreach ($orgResponses as $orgResponse) {
$this->fetchRepos($orgResponse);
if ($orgResponse->hasHeader('link')) {
$link = $orgResponse->getHeader('link');
if (preg_match('/.* <(.+?)\\?page=(\\d+)>; rel="last"$/', $link, $matches)) {
$pagesRequests = [];
for ($i = 2; $i <= $matches[2]; $i++) {
$this->logger->debug(sprintf('adding "' . ($matches[1] . '?page=' . $i) . '" for crawl'));
$pagesRequests[] = $client->get($matches[1] . '?page=' . $i);
}
$pagesResponses = $client->send($pagesRequests);
foreach ($pagesResponses as $pagesResponse) {
$this->fetchRepos($pagesResponse);
}
}
}
}
return $this->getImportableProjects();
}
示例2: configureClientForUser
/**
* @param User $user
*
* @return Client
*/
public function configureClientForUser(User $user)
{
$accessToken = $user->getProviderAccessToken($this->getName());
return $this->configureClientForAccessToken($accessToken);
}
示例3: setUser
/**
* {@inheritDoc}
*/
public function setUser(User $user)
{
$this->user = $user;
$providerName = $this->getProvider()->getName();
if (strlen($user->hasProviderAccessToken($providerName))) {
$this->setAccessToken($user->getProviderAccessToken($providerName));
}
return $this;
}