You are here

class SalesforceOAuthCredentials in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 5.0.x modules/salesforce_oauth/src/Consumer/SalesforceOAuthCredentials.php \Drupal\salesforce_oauth\Consumer\SalesforceOAuthCredentials

Salesforce credentials extension, for drupalisms.

Hierarchy

Expanded class hierarchy of SalesforceOAuthCredentials

File

modules/salesforce_oauth/src/Consumer/SalesforceOAuthCredentials.php, line 11

Namespace

Drupal\salesforce_oauth\Consumer
View source
class SalesforceOAuthCredentials 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_oauth\Consumer\SalesforceOAuthCredentials
   *   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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SalesforceCredentials::$consumerKey protected property Consumer key for the Salesforce connected OAuth app.
SalesforceCredentials::$loginUrl protected property Login URL e.g. https://test.salesforce.com or https://login.salesforce.com.
SalesforceCredentials::getConsumerKey public function Get the consumer key for these credentials. Overrides SalesforceCredentialsInterface::getConsumerKey
SalesforceCredentials::getLoginUrl public function Get the login URL for these credentials. Overrides SalesforceCredentialsInterface::getLoginUrl
SalesforceOAuthCredentials::callbackUrl public static function Static wrapper to generate the callback url from the callback route.
SalesforceOAuthCredentials::create public static function Constructor helper. Overrides SalesforceCredentials::create
SalesforceOAuthCredentials::getCallbackUrl public function
SalesforceOAuthCredentials::isValid public function Sanity check for credentials validity. Overrides SalesforceCredentials::isValid
SalesforceOAuthCredentials::__construct public function