/**
  * {@inheritdoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $user_manager = $this->container->get('glory_user.user_manager');
     $resourceOwnerName = $response->getResourceOwner()->getName();
     $oauth = $user_manager->findOAuth(array('owner' => $resourceOwnerName, 'username' => $response->getUsername()));
     if (!$oauth) {
         $oauth = $user_manager->createOAuthFromResponse($response);
     } else {
         $user_manager->updateOAuthFromResponse($oauth, $response, true);
     }
     if (!$oauth || null == ($user = $oauth->getUser())) {
         //throw new AccountNotLinkedException(sprintf("User '%s' not found.", $response->getUsername()));
         $exception = new AccountNotLinkedException(sprintf("User '%s' not found.", $response->getUsername()));
         $exception->setUsername($response->getUsername());
         throw $exception;
     }
     return $user;
 }
 /**
  * @return AccountNotLinkedException
  */
 protected function createAccountNotLinkedException()
 {
     $accountNotLinked = new AccountNotLinkedException();
     $accountNotLinked->setResourceOwnerName('facebook');
     $token = new CustomOAuthToken();
     $accountNotLinked->setToken($token);
     return $accountNotLinked;
 }