37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace KupShop\UserOauthBundle\ResourceOwner;
|
|
|
|
use HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\FacebookResourceOwner;
|
|
use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
|
|
|
|
class CustomFacebookResourceOwner extends CustomResourceOwner
|
|
{
|
|
public function createResourceOwner($httpClient, $httpUtils, $options, $name, $storage)
|
|
{
|
|
return new FacebookResourceOwner($httpClient, $httpUtils, $options, $name, $storage);
|
|
}
|
|
|
|
/**
|
|
* Get the url to the profile picture.
|
|
*
|
|
* @return string|null
|
|
*/
|
|
protected function getProfilePicture(?string $user_name = null)
|
|
{
|
|
if ($user_name) {
|
|
return 'https://graph.facebook.com/'.$user_name.'/picture?type=square';
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public function updateUserData(\User $user, UserResponseInterface $response)
|
|
{
|
|
$profilePicture = $this->getProfilePicture($response->getUsername());
|
|
if ($profilePicture) {
|
|
$user->setCustomData('profilePicture', $profilePicture);
|
|
}
|
|
}
|
|
}
|