Ojs\UserBundle\Provider\FOSUBUserProvider::connect PHP Метод

connect() публичный Метод

public connect ( Symfony\Component\Security\Core\User\UserInterface $user, HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface $response )
$user Symfony\Component\Security\Core\User\UserInterface
$response HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface
    public function connect(UserInterface $user, UserResponseInterface $response)
    {
        $service = $response->getResourceOwner()->getName();
        /** @var UserOauthAccount $connection */
        $connection = $this->em->getRepository('OjsUserBundle:UserOauthAccount')->findOneBy(['providerId' => $response->getUsername(), 'provider' => $service]);
        if ($connection && $connection->getUser()->getUsername() !== $user->getUsername()) {
            $this->em->remove($connection);
            $connection = null;
        }
        if (!$connection) {
            $connection = new UserOauthAccount();
            $connection->setUser($user);
            $connection->setProvider($service);
            $connection->setProviderId($response->getUsername());
        }
        $connection->setToken($response->getAccessToken());
        $this->em->persist($connection);
        $this->em->flush();
    }