SecretInfo.php in Lockr 8.3
File
src/SecretInfo.php
View source
<?php
namespace Drupal\lockr;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\key\KeyRepositoryInterface;
use Lockr\SecretInfoInterface;
class SecretInfo implements SecretInfoInterface {
protected $configFactory;
protected $keyRepository;
public function __construct(ConfigFactoryInterface $config_factory, KeyRepositoryInterface $key_repository) {
$this->configFactory = $config_factory;
$this->keyRepository = $key_repository;
}
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 ?: [];
}
public function setSecretInfo($name, array $info) {
$config = $this->configFactory
->getEditable('lockr.secret_info');
$config
->set($name, $info);
$config
->save();
}
public function getAllSecretInfo() {
$config = $this->configFactory
->get('lockr.secret_info');
return $config
->get();
}
}
Classes
Name |
Description |
SecretInfo |
SecretInfo implements secret info for Lockr secrets. |