You are here

public function OAuthKey::exists in Lightning API 8

Same name and namespace in other branches
  1. 8.4 src/OAuthKey.php \Drupal\lightning_api\OAuthKey::exists()
  2. 8.2 src/OAuthKey.php \Drupal\lightning_api\OAuthKey::exists()
  3. 8.3 src/OAuthKey.php \Drupal\lightning_api\OAuthKey::exists()

Checks if one or both OAuth key components exist.

Parameters

string $which: (optional) Which key component to check. Can be 'public' or 'private'. If omitted, both components are checked.

Return value

bool TRUE if the key component(s) exist, FALSE otherwise.

File

src/OAuthKey.php, line 57

Class

OAuthKey

Namespace

Drupal\lightning_api

Code

public function exists($which = NULL) {
  if ($which) {
    $key = $this->configFactory
      ->get('simple_oauth.settings')
      ->get("{$which}_key");
    return $key && file_exists($key) && (fileperms($key) & 0777) === static::PERMISSIONS;
  }
  else {
    return $this
      ->exists('private') && $this
      ->exists('public');
  }
}