You are here

public function LinkedInAuthController::getSdk in Open Social 8.7

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

Returns the SDK instance or RedirectResponse when error occurred.

Parameters

string $type: Type of action, "login" or "register".

Return value

mixed|\Symfony\Component\HttpFoundation\RedirectResponse Returns an instance of the SDK or a Redirect Response.

3 calls to LinkedInAuthController::getSdk()
LinkedInAuthController::getRedirectResponse in modules/custom/social_auth_linkedin/src/Controller/LinkedInAuthController.php
Returns the redirect response.
LinkedInAuthController::userLoginCallback in modules/custom/social_auth_linkedin/src/Controller/LinkedInAuthController.php
Authorizes the user after redirect from LinkedIn.
LinkedInAuthController::userRegisterCallback in modules/custom/social_auth_linkedin/src/Controller/LinkedInAuthController.php
Registers the new account after redirect from LinkedIn.

File

modules/custom/social_auth_linkedin/src/Controller/LinkedInAuthController.php, line 201

Class

LinkedInAuthController
Class LinkedInAuthController.

Namespace

Drupal\social_auth_linkedin\Controller

Code

public function getSdk($type) {
  $network_manager = $this->networkManager
    ->createInstance('social_auth_linkedin');
  if (!$network_manager
    ->isActive()) {
    drupal_set_message($this
      ->t('@network is disabled. Contact the site administrator', [
      '@network' => $this
        ->t('LinkedIn'),
    ]), 'error');
    return $this
      ->redirect('user.' . $type);
  }
  if (!($sdk = $network_manager
    ->getSdk())) {
    drupal_set_message($this
      ->t('@network Auth not configured properly. Contact the site administrator.', [
      '@network' => $this
        ->t('LinkedIn'),
    ]), 'error');
    return $this
      ->redirect('user.' . $type);
  }
  return $sdk;
}