class OAuthCredentials in Salesforce Suite 8.3
Salesforce credentials extension, for drupalisms.
Hierarchy
- class \Drupal\salesforce\Consumer\SalesforceCredentials extends \OAuth\Common\Consumer\Credentials implements SalesforceCredentialsInterface
- class \Drupal\salesforce\Consumer\OAuthCredentials
Expanded class hierarchy of OAuthCredentials
1 file declares its use of OAuthCredentials
- SalesforceOAuthPlugin.php in src/
Plugin/ SalesforceAuthProvider/ SalesforceOAuthPlugin.php
File
- src/
Consumer/ OAuthCredentials.php, line 10
Namespace
Drupal\salesforce\ConsumerView source
class OAuthCredentials extends SalesforceCredentials {
/**
* {@inheritdoc}
*/
public function __construct($consumerKey, $consumerSecret, $loginUrl) {
parent::__construct($consumerKey, $consumerSecret, self::callbackUrl());
$this->consumerKey = $consumerKey;
$this->loginUrl = $loginUrl;
}
/**
* Constructor helper.
*
* @param array $configuration
* Plugin configuration.
*
* @return \Drupal\salesforce\Consumer\OAuthCredentials
* Credentials, valid or not.
*/
public static function create(array $configuration) {
return new static($configuration['consumer_key'], $configuration['consumer_secret'], $configuration['login_url']);
}
/**
* {@inheritdoc}
*/
public function getCallbackUrl() {
return self::callbackUrl();
}
/**
* Static wrapper to generate the callback url from the callback route.
*
* @return string
* The callback URL.
*/
public static function callbackUrl() {
return Url::fromRoute('salesforce.oauth_callback', [], [
'absolute' => TRUE,
'https' => TRUE,
])
->toString();
}
/**
* {@inheritdoc}
*/
public function isValid() {
return !empty($this->loginUrl) && !empty($this->consumerSecret) && !empty($this->consumerId);
}
}