You are here

abstract class StorageBase in Checklist API 8

Provides a base storage implementation for others to extend.

Hierarchy

Expanded class hierarchy of StorageBase

File

src/Storage/StorageBase.php, line 8

Namespace

Drupal\checklistapi\Storage
View source
abstract class StorageBase implements StorageInterface {

  /**
   * The checklist ID.
   *
   * @var string
   */
  private $checklistId;

  /**
   * Sets the checklist ID.
   *
   * @param string $id
   *   The checklist ID.
   *
   * @return self
   *   The storage object.
   */
  public function setChecklistId($id) {
    if (!is_string($id)) {
      throw new \InvalidArgumentException('A checklist ID must be a string.');
    }
    $this->checklistId = $id;
    return $this;
  }

  /**
   * Gets the checklist ID.
   *
   * @return string
   *   Returns the checklist ID.
   */
  protected function getChecklistId() {
    if (empty($this->checklistId)) {
      throw new \LogicException('You must set the checklist ID before accessing saved progress.');
    }
    return $this->checklistId;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StorageBase::$checklistId private property The checklist ID.
StorageBase::getChecklistId protected function Gets the checklist ID.
StorageBase::setChecklistId public function Sets the checklist ID. Overrides StorageInterface::setChecklistId
StorageInterface::deleteSavedProgress public function Deletes the saved checklist progress. 2
StorageInterface::getSavedProgress public function Gets the saved checklist progress. 2
StorageInterface::setSavedProgress public function Sets the saved checklist progress. 2