class StateStorage in Checklist API 8
Provides state-based checklist progress storage.
Hierarchy
- class \Drupal\checklistapi\Storage\StorageBase implements StorageInterface
- class \Drupal\checklistapi\Storage\StateStorage
Expanded class hierarchy of StateStorage
1 string reference to 'StateStorage'
1 service uses StateStorage
File
- src/
Storage/ StateStorage.php, line 10
Namespace
Drupal\checklistapi\StorageView source
class StateStorage extends StorageBase {
/**
* The state service.
*
* @var \Drupal\Core\State\StateInterface
*/
private $state;
/**
* Constructs a class instance.
*
* @param \Drupal\Core\State\StateInterface $state
* The state service.
*/
public function __construct(StateInterface $state) {
$this->state = $state;
}
/**
* {@inheritdoc}
*/
public function getSavedProgress() {
return $this->state
->get($this
->stateKey());
}
/**
* {@inheritdoc}
*/
public function setSavedProgress(array $progress) {
$this->state
->set($this
->stateKey(), $progress);
}
/**
* {@inheritdoc}
*/
public function deleteSavedProgress() {
$this->state
->delete($this
->stateKey());
}
/**
* Returns the state key.
*
* @return string
* The state key.
*/
private function stateKey() {
return 'checklistapi.progress.' . $this
->getChecklistId();
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
StateStorage:: |
private | property | The state service. | |
StateStorage:: |
public | function |
Deletes the saved checklist progress. Overrides StorageInterface:: |
|
StateStorage:: |
public | function |
Gets the saved checklist progress. Overrides StorageInterface:: |
|
StateStorage:: |
public | function |
Sets the saved checklist progress. Overrides StorageInterface:: |
|
StateStorage:: |
private | function | Returns the state key. | |
StateStorage:: |
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:: |