You are here

class SecretInfo in Lockr 8.3

Same name and namespace in other branches
  1. 8.4 src/SecretInfo.php \Drupal\lockr\SecretInfo
  2. 4.x src/SecretInfo.php \Drupal\lockr\SecretInfo

SecretInfo implements secret info for Lockr secrets.

Hierarchy

  • class \Drupal\lockr\SecretInfo implements \Lockr\SecretInfoInterface

Expanded class hierarchy of SecretInfo

1 string reference to 'SecretInfo'
lockr.services.yml in ./lockr.services.yml
lockr.services.yml
1 service uses SecretInfo
lockr.secret_info in ./lockr.services.yml
Drupal\lockr\SecretInfo

File

src/SecretInfo.php, line 12

Namespace

Drupal\lockr
View source
class SecretInfo implements SecretInfoInterface {

  /**
   * Simple config factory.
   *
   * @var ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Key repository.
   *
   * @var KeyRepositoryInterface
   */
  protected $keyRepository;

  /**
   * Constructs a new settings factory.
   *
   * @param ConfigFactoryInterface $config_factory
   *   The simple config factory.
   * @param KeyRepositoryInterface $key_repository
   *   The key respository.
   */
  public function __construct(ConfigFactoryInterface $config_factory, KeyRepositoryInterface $key_repository) {
    $this->configFactory = $config_factory;
    $this->keyRepository = $key_repository;
  }

  /**
   * {@inheritdoc}
   */
  public function getSecretInfo($name) {
    $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 ?: [];
  }

  /**
   * {@inheritdoc}
   */
  public function setSecretInfo($name, array $info) {
    $config = $this->configFactory
      ->getEditable('lockr.secret_info');
    $config
      ->set($name, $info);
    $config
      ->save();
  }

  /**
   * {@inheritdoc}
   */
  public function getAllSecretInfo() {
    $config = $this->configFactory
      ->get('lockr.secret_info');
    return $config
      ->get();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SecretInfo::$configFactory protected property Simple config factory.
SecretInfo::$keyRepository protected property Key repository.
SecretInfo::getAllSecretInfo public function
SecretInfo::getSecretInfo public function
SecretInfo::setSecretInfo public function
SecretInfo::__construct public function Constructs a new settings factory.