You are here

abstract class AuthManager in Open Social 8.5

Same name and namespace in other branches
  1. 8.9 modules/custom/social_auth_extra/src/AuthManager.php \Drupal\social_auth_extra\AuthManager
  2. 8 modules/custom/social_auth_extra/src/AuthManager.php \Drupal\social_auth_extra\AuthManager
  3. 8.2 modules/custom/social_auth_extra/src/AuthManager.php \Drupal\social_auth_extra\AuthManager
  4. 8.3 modules/custom/social_auth_extra/src/AuthManager.php \Drupal\social_auth_extra\AuthManager
  5. 8.4 modules/custom/social_auth_extra/src/AuthManager.php \Drupal\social_auth_extra\AuthManager
  6. 8.6 modules/custom/social_auth_extra/src/AuthManager.php \Drupal\social_auth_extra\AuthManager
  7. 8.7 modules/custom/social_auth_extra/src/AuthManager.php \Drupal\social_auth_extra\AuthManager
  8. 8.8 modules/custom/social_auth_extra/src/AuthManager.php \Drupal\social_auth_extra\AuthManager

Class AuthManager.

@package Drupal\social_auth_extra

Hierarchy

Expanded class hierarchy of AuthManager

4 files declare their use of AuthManager
FacebookAuthManager.php in modules/custom/social_auth_facebook/src/FacebookAuthManager.php
GoogleAuthManager.php in modules/custom/social_auth_google/src/GoogleAuthManager.php
LinkedInAuthManager.php in modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php
TwitterAuthManager.php in modules/custom/social_auth_twitter/src/TwitterAuthManager.php

File

modules/custom/social_auth_extra/src/AuthManager.php, line 15

Namespace

Drupal\social_auth_extra
View source
abstract class AuthManager implements AuthManagerInterface {
  protected $urlGenerator;
  protected $entityFieldManager;
  protected $loggerFactory;

  /**
   * Object of SDK to work with API of social network.
   *
   * @var object
   */
  protected $sdk;

  /**
   * Contains object of a profile received from a social network.
   *
   * @var mixed
   */
  protected $profile;

  /**
   * Contains the field definition with a profile picture.
   *
   * @var \Drupal\Core\Field\FieldDefinitionInterface
   */
  protected $fieldPicture;

  /**
   * AuthManager constructor.
   */
  public function __construct(UrlGeneratorInterface $urlGenerator, EntityFieldManagerInterface $entity_field_manager, LoggerChannelFactoryInterface $logger_factory) {
    $this->urlGenerator = $urlGenerator;
    $this->entityFieldManager = $entity_field_manager;
    $this->loggerFactory = $logger_factory;
  }

  /**
   * {@inheritdoc}
   */
  public function getRedirectUrl($type) {
    $key = $this
      ->getSocialNetworkKey();
    return $this->urlGenerator
      ->generateFromRoute("social_auth_{$key}.user_{$type}_callback", [], [
      'absolute' => TRUE,
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function getPreferredResolution() {

    // Check whether field is exists.
    if (!$this->fieldPicture instanceof FieldDefinitionInterface) {
      return FALSE;
    }
    $max_resolution = $this->fieldPicture
      ->getSetting('max_resolution');
    $min_resolution = $this->fieldPicture
      ->getSetting('min_resolution');

    // Return order: max resolution, min resolution, FALSE.
    if ($max_resolution) {
      $resolution = $max_resolution;
    }
    elseif ($min_resolution) {
      $resolution = $min_resolution;
    }
    else {
      return FALSE;
    }
    $dimensions = explode('x', $resolution);
    return array_combine([
      'width',
      'height',
    ], $dimensions);
  }

  /**
   * {@inheritdoc}
   */
  public function getUsername() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function setFieldPicture(FieldDefinitionInterface $field) {
    $this->fieldPicture = $field;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AuthManager::$entityFieldManager protected property
AuthManager::$fieldPicture protected property Contains the field definition with a profile picture.
AuthManager::$loggerFactory protected property
AuthManager::$profile protected property Contains object of a profile received from a social network.
AuthManager::$sdk protected property Object of SDK to work with API of social network.
AuthManager::$urlGenerator protected property
AuthManager::getPreferredResolution public function Determines preferred profile pic resolution from account settings. Overrides AuthManagerInterface::getPreferredResolution
AuthManager::getRedirectUrl public function Returns URL to authorize/registration depending on type. Overrides AuthManagerInterface::getRedirectUrl
AuthManager::getUsername public function Returns user on a social network if it possible. Overrides AuthManagerInterface::getUsername 1
AuthManager::setFieldPicture public function Set an instance of a field definition that contains picture. Overrides AuthManagerInterface::setFieldPicture
AuthManager::__construct public function AuthManager constructor.
AuthManagerInterface::getAccessToken public function Reads user's access token from social network. 4
AuthManagerInterface::getAccountId public function Returns an account ID on a social network. 4
AuthManagerInterface::getAuthenticationUrl public function Returns the login URL where user will be redirected for authentication. 4
AuthManagerInterface::getFirstName public function Returns first name on a social network if it possible. 4
AuthManagerInterface::getLastName public function Returns last name on a social network if it possible. 4
AuthManagerInterface::getProfile public function Returns object of a user profile. 4
AuthManagerInterface::getProfilePicture public function Returns URL of a profile picture. 4
AuthManagerInterface::getSocialNetworkKey public function Returns key-name of a social network. 4
AuthManagerInterface::setAccessToken public function Set access token to AuthManager to use it for API calls. 4
AuthManagerInterface::setSdk public function Set instance of SDK. 4