You are here

public function Storage::setIfNotExists in Express 8

Saves a value for a given key if it does not exist yet.

Parameters

string $key: The key of the data to store.

mixed $value: The data to store.

Return value

bool TRUE if the data was set, FALSE if it already existed.

Overrides MemoryStorage::setIfNotExists

File

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

Class

Storage
Theme Storage.

Namespace

Drupal\bootstrap\Utility

Code

public function setIfNotExists($key, $value) {
  if (!isset($this->data[$key])) {
    if (is_array($value)) {
      $value = new StorageItem($value, $this);
    }
    $this->data[$key] = $value;
    $this
      ->changed();
    return TRUE;
  }
  return FALSE;
}