class ConfigStorage in Checklist API 8
Provides config-based checklist progress storage.
Hierarchy
- class \Drupal\checklistapi\Storage\StorageBase implements StorageInterface
- class \Drupal\checklistapi\Storage\ConfigStorage
Expanded class hierarchy of ConfigStorage
1 string reference to 'ConfigStorage'
1 service uses ConfigStorage
File
- src/
Storage/ ConfigStorage.php, line 10
Namespace
Drupal\checklistapi\StorageView source
class ConfigStorage extends StorageBase {
/**
* The configuration key for saved progress.
*/
const CONFIG_KEY = 'progress';
/**
* The config object.
*
* @var \Drupal\Core\Config\Config|null
*/
private $config;
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
private $configFactory;
/**
* Constructs a class instance.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
*/
public function __construct(ConfigFactoryInterface $config_factory) {
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
public function getSavedProgress() {
return $this
->getConfig()
->get(self::CONFIG_KEY);
}
/**
* {@inheritdoc}
*/
public function setSavedProgress(array $progress) {
$this
->getConfig()
->set(self::CONFIG_KEY, $progress)
->save();
}
/**
* {@inheritdoc}
*/
public function deleteSavedProgress() {
$this
->getConfig()
->delete();
}
/**
* Gets the config object.
*
* @return \Drupal\Core\Config\Config
* Returns the config object.
*/
private function getConfig() {
if (empty($this->config)) {
$this->config = $this->configFactory
->getEditable("checklistapi.progress.{$this->getChecklistId()}");
}
return $this->config;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigStorage:: |
private | property | The config object. | |
ConfigStorage:: |
private | property | The config factory. | |
ConfigStorage:: |
constant | The configuration key for saved progress. | ||
ConfigStorage:: |
public | function |
Deletes the saved checklist progress. Overrides StorageInterface:: |
|
ConfigStorage:: |
private | function | Gets the config object. | |
ConfigStorage:: |
public | function |
Gets the saved checklist progress. Overrides StorageInterface:: |
|
ConfigStorage:: |
public | function |
Sets the saved checklist progress. Overrides StorageInterface:: |
|
ConfigStorage:: |
public | function | Constructs a class instance. | |
StorageBase:: |
private | property | The checklist ID. | |
StorageBase:: |
protected | function | Gets the checklist ID. | |
StorageBase:: |
public | function |
Sets the checklist ID. Overrides StorageInterface:: |