You are here

public function SecretInfo::getSecretInfo in Lockr 4.x

Same name and namespace in other branches
  1. 8.4 src/SecretInfo.php \Drupal\lockr\SecretInfo::getSecretInfo()
  2. 8.3 src/SecretInfo.php \Drupal\lockr\SecretInfo::getSecretInfo()

File

src/SecretInfo.php, line 53

Class

SecretInfo
SecretInfo implements secret info for Lockr secrets.

Namespace

Drupal\lockr

Code

public function getSecretInfo($name) {

  /** @var \Drupal\lockr\SecretInterface */
  $secret = $this->secretStorage
    ->load($name);
  if (!is_null($secret)) {
    return $secret
      ->getInfo();
  }
  $config = $this->configFactory
    ->get('lockr.secret_info');
  $info = $config
    ->get($name);
  if (!$info) {
    $key = $this->keyRepository
      ->getKey($name);
    if ($key) {
      $provider = $key
        ->getKeyProvider();
      $config = $provider
        ->getConfiguration();
      if (isset($config['encoded'])) {
        return [
          'wrapping_key' => $config['encoded'],
        ];
      }
    }
  }
  return $info ?: [];
}