You are here

public function GoogleLinkController::getSdk in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 modules/custom/social_auth_google/src/Controller/GoogleLinkController.php \Drupal\social_auth_google\Controller\GoogleLinkController::getSdk()
  2. 8 modules/custom/social_auth_google/src/Controller/GoogleLinkController.php \Drupal\social_auth_google\Controller\GoogleLinkController::getSdk()
  3. 8.2 modules/custom/social_auth_google/src/Controller/GoogleLinkController.php \Drupal\social_auth_google\Controller\GoogleLinkController::getSdk()
  4. 8.3 modules/custom/social_auth_google/src/Controller/GoogleLinkController.php \Drupal\social_auth_google\Controller\GoogleLinkController::getSdk()
  5. 8.4 modules/custom/social_auth_google/src/Controller/GoogleLinkController.php \Drupal\social_auth_google\Controller\GoogleLinkController::getSdk()
  6. 8.5 modules/custom/social_auth_google/src/Controller/GoogleLinkController.php \Drupal\social_auth_google\Controller\GoogleLinkController::getSdk()
  7. 8.6 modules/custom/social_auth_google/src/Controller/GoogleLinkController.php \Drupal\social_auth_google\Controller\GoogleLinkController::getSdk()
  8. 8.7 modules/custom/social_auth_google/src/Controller/GoogleLinkController.php \Drupal\social_auth_google\Controller\GoogleLinkController::getSdk()

Returns the SDK instance or RedirectResponse when error occurred.

Return value

mixed|\Symfony\Component\HttpFoundation\RedirectResponse Can return an SDK instance or a RedirectResponse to the user edit form.

2 calls to GoogleLinkController::getSdk()
GoogleLinkController::linkAccount in modules/custom/social_auth_google/src/Controller/GoogleLinkController.php
Response for path 'social-api/link/google'.
GoogleLinkController::linkAccountCallback in modules/custom/social_auth_google/src/Controller/GoogleLinkController.php
Makes joining between account on this site and account on social network.

File

modules/custom/social_auth_google/src/Controller/GoogleLinkController.php, line 128

Class

GoogleLinkController
Class GoogleLinkController.

Namespace

Drupal\social_auth_google\Controller

Code

public function getSdk() {
  $network_manager = $this->networkManager
    ->createInstance('social_auth_google');
  if (!$network_manager
    ->isActive()) {
    drupal_set_message($this
      ->t('@network is disallowed. Contact site administrator.', [
      '@network' => $this
        ->t('Google'),
    ]), 'error');
    return $this
      ->redirect('entity.user.edit_form', [
      'user' => $this
        ->currentUser()
        ->id(),
    ]);
  }
  if (!($sdk = $network_manager
    ->getSdk())) {
    drupal_set_message($this
      ->t('@network Auth not configured properly. Contact site administrator.', [
      '@network' => $this
        ->t('Google'),
    ]), 'error');
    return $this
      ->redirect('entity.user.edit_form', [
      'user' => $this
        ->currentUser()
        ->id(),
    ]);
  }
  return $sdk;
}