AuthManager.php in Open Social 8
File
modules/custom/social_auth_extra/src/AuthManager.php
View source
<?php
namespace Drupal\social_auth_extra;
use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
abstract class AuthManager implements AuthManagerInterface {
protected $urlGenerator;
protected $entityFieldManager;
protected $loggerFactory;
protected $sdk;
protected $profile;
protected $fieldPicture;
public function __construct(UrlGeneratorInterface $urlGenerator, EntityFieldManagerInterface $entity_field_manager, LoggerChannelFactoryInterface $logger_factory) {
$this->urlGenerator = $urlGenerator;
$this->entityFieldManager = $entity_field_manager;
$this->loggerFactory = $logger_factory;
}
public function getRedirectUrl($type) {
$key = $this
->getSocialNetworkKey();
return $this->urlGenerator
->generateFromRoute("social_auth_{$key}.user_{$type}_callback", [], [
'absolute' => TRUE,
]);
}
public function getPreferredResolution() {
if (!$this->fieldPicture instanceof FieldDefinitionInterface) {
return FALSE;
}
$max_resolution = $this->fieldPicture
->getSetting('max_resolution');
$min_resolution = $this->fieldPicture
->getSetting('min_resolution');
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);
}
public function getUsername() {
return FALSE;
}
public function setFieldPicture(FieldDefinitionInterface $field) {
$this->fieldPicture = $field;
}
}