class FacebookAuth in Social Auth Facebook 3.x
Same name and namespace in other branches
- 8.2 src/Plugin/Network/FacebookAuth.php \Drupal\social_auth_facebook\Plugin\Network\FacebookAuth
- 8 src/Plugin/Network/FacebookAuth.php \Drupal\social_auth_facebook\Plugin\Network\FacebookAuth
Defines a Network Plugin for Social Auth Facebook.
@package Drupal\social_auth_facebook\Plugin\Network
Plugin annotation
@Network(
id = "social_auth_facebook",
social_network = "Facebook",
type = "social_auth",
handlers = {
"settings": {
"class": "\Drupal\social_auth_facebook\Settings\FacebookAuthSettings",
"config_id": "social_auth_facebook.settings"
}
}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\social_api\Plugin\NetworkBase implements NetworkInterface
- class \Drupal\social_auth\Plugin\Network\NetworkBase implements NetworkInterface
- class \Drupal\social_auth_facebook\Plugin\Network\FacebookAuth implements FacebookAuthInterface
- class \Drupal\social_auth\Plugin\Network\NetworkBase implements NetworkInterface
- class \Drupal\social_api\Plugin\NetworkBase implements NetworkInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of FacebookAuth
File
- src/
Plugin/ Network/ FacebookAuth.php, line 28
Namespace
Drupal\social_auth_facebook\Plugin\NetworkView source
class FacebookAuth extends NetworkBase implements FacebookAuthInterface {
/**
* Sets the underlying SDK library.
*
* @return \League\OAuth2\Client\Provider\Facebook|false
* The initialized 3rd party library instance.
* False if library could not be initialized.
*
* @throws \Drupal\social_api\SocialApiException
* If the SDK library does not exist.
*/
protected function initSdk() {
$class_name = '\\League\\OAuth2\\Client\\Provider\\Facebook';
if (!class_exists($class_name)) {
throw new SocialApiException(sprintf('The PHP League OAuth2 library for Facebook not found. Class: %s.', $class_name));
}
/** @var \Drupal\social_auth_facebook\Settings\FacebookAuthSettings $settings */
$settings = $this->settings;
if ($this
->validateConfig($settings)) {
// All these settings are mandatory.
$league_settings = [
'clientId' => $settings
->getAppId(),
'clientSecret' => $settings
->getAppSecret(),
'redirectUri' => Url::fromRoute('social_auth_facebook.callback')
->setAbsolute()
->toString(),
'graphApiVersion' => 'v' . $settings
->getGraphVersion(),
];
// Proxy configuration data for outward proxy.
$config = $this->siteSettings
->get('http_client_config');
if (!empty($config['proxy']['http'])) {
$league_settings['proxy'] = $config['proxy']['http'];
}
return new Facebook($league_settings);
}
return FALSE;
}
/**
* Checks that module is configured.
*
* @param \Drupal\social_auth_facebook\Settings\FacebookAuthSettings $settings
* The Social Auth Facebook settings.
*
* @return bool
* True if module is configured.
* False otherwise.
*/
protected function validateConfig(FacebookAuthSettings $settings) {
$app_id = $settings
->getAppId();
$app_secret = $settings
->getAppSecret();
$graph_version = $settings
->getGraphVersion();
if (!$app_id || !$app_secret || !$graph_version) {
$this->loggerFactory
->get('social_auth_facebook')
->error('Define App ID and App Secret on module settings.');
return FALSE;
}
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
FacebookAuth:: |
protected | function |
Sets the underlying SDK library. Overrides NetworkBase:: |
|
FacebookAuth:: |
protected | function | Checks that module is configured. | |
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
NetworkBase:: |
protected | property | The entity type manager. | |
NetworkBase:: |
protected | property | The logger factory. | |
NetworkBase:: |
protected | property | The SDK client. | |
NetworkBase:: |
protected | property | The implementer/plugin settings. | |
NetworkBase:: |
protected | property | The global site settings. | |
NetworkBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
NetworkBase:: |
public | function |
Gets the underlying SDK library. Overrides NetworkInterface:: |
|
NetworkBase:: |
protected | function | Initialize the plugin. | |
NetworkBase:: |
public | function |
Instantiates a NetworkBase object. Overrides PluginBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |