You are here

public function KeyProvider::getCredentials in Entity Share 8.3

Get the provided credentials.

Parameters

\Drupal\entity_share_client\ClientAuthorization\ClientAuthorizationInterface $plugin: An authorization plugin.

Return value

array|string The value of the configured key.

File

modules/entity_share_client/src/Service/KeyProvider.php, line 72

Class

KeyProvider
Abstraction layer to support local storage and Key module.

Namespace

Drupal\entity_share_client\Service

Code

public function getCredentials(ClientAuthorizationInterface $plugin) {
  $provider = $plugin
    ->getCredentialProvider();
  $credentials = [];
  if (empty($provider)) {
    return $credentials;
  }
  switch ($provider) {
    case 'key':
      $keyEntity = $this->keyRepository
        ->getKey($plugin
        ->getStorageKey());
      if ($keyEntity instanceof Key) {

        // A key was found in the repository.
        $credentials = $keyEntity
          ->getKeyValues();
      }
      break;
    default:
      $credentials = $this->keyValueStore
        ->get($plugin
        ->getStorageKey());
  }
  return $credentials;
}