You are here

public function LinkedInLinkController::getSdk in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/custom/social_auth_linkedin/src/Controller/LinkedInLinkController.php \Drupal\social_auth_linkedin\Controller\LinkedInLinkController::getSdk()
  2. 8.2 modules/custom/social_auth_linkedin/src/Controller/LinkedInLinkController.php \Drupal\social_auth_linkedin\Controller\LinkedInLinkController::getSdk()
  3. 8.3 modules/custom/social_auth_linkedin/src/Controller/LinkedInLinkController.php \Drupal\social_auth_linkedin\Controller\LinkedInLinkController::getSdk()
  4. 8.4 modules/custom/social_auth_linkedin/src/Controller/LinkedInLinkController.php \Drupal\social_auth_linkedin\Controller\LinkedInLinkController::getSdk()
  5. 8.5 modules/custom/social_auth_linkedin/src/Controller/LinkedInLinkController.php \Drupal\social_auth_linkedin\Controller\LinkedInLinkController::getSdk()
  6. 8.6 modules/custom/social_auth_linkedin/src/Controller/LinkedInLinkController.php \Drupal\social_auth_linkedin\Controller\LinkedInLinkController::getSdk()
  7. 8.7 modules/custom/social_auth_linkedin/src/Controller/LinkedInLinkController.php \Drupal\social_auth_linkedin\Controller\LinkedInLinkController::getSdk()
  8. 8.8 modules/custom/social_auth_linkedin/src/Controller/LinkedInLinkController.php \Drupal\social_auth_linkedin\Controller\LinkedInLinkController::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 LinkedInLinkController::getSdk()
LinkedInLinkController::linkAccount in modules/custom/social_auth_linkedin/src/Controller/LinkedInLinkController.php
Response for path 'social-api/link/linkedin'.
LinkedInLinkController::linkAccountCallback in modules/custom/social_auth_linkedin/src/Controller/LinkedInLinkController.php
Makes joining between account on this site and account on social network.

File

modules/custom/social_auth_linkedin/src/Controller/LinkedInLinkController.php, line 128

Class

LinkedInLinkController
Class LinkedInLinkController.

Namespace

Drupal\social_auth_linkedin\Controller

Code

public function getSdk() {
  $network_manager = $this->networkManager
    ->createInstance('social_auth_linkedin');
  if (!$network_manager
    ->isActive()) {
    drupal_set_message($this
      ->t('@network is disallowed. Contact site administrator.', [
      '@network' => $this
        ->t('LinkedIn'),
    ]), '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('LinkedIn'),
    ]), 'error');
    return $this
      ->redirect('entity.user.edit_form', [
      'user' => $this
        ->currentUser()
        ->id(),
    ]);
  }
  return $sdk;
}