You are here

public function Storage::__construct in Express 8

Overrides StorageBase::__construct

File

themes/contrib/bootstrap/src/Utility/Storage.php, line 79
Contains \Drupal\bootstrap\Utility\Storage.

Class

Storage
Theme Storage.

Namespace

Drupal\bootstrap\Utility

Code

public function __construct($cid, $bin = 'default', $expire = Cache::PERMANENT, $tags = [
  Bootstrap::CACHE_TAG,
]) {
  $this->cid = "theme_registry:storage:{$cid}";
  $this->bin = $bin;
  $this->changed = FALSE;
  $this->expire = $expire;
  $this->tags = $tags;

  // Register the cache object to save, if it's needed, on shutdown.
  drupal_register_shutdown_function([
    $this,
    'save',
  ]);

  // Retrieve the cached data.
  $data = ($cached = \Drupal::cache($bin)
    ->get($this->cid)) && !empty($cached->data) ? $cached->data : [];

  // Set the data.
  $this
    ->setMultiple($data);

  // Cache has been initialized.
  $this->initialized = TRUE;
}