You are here

public function StorageItem::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/StorageItem.php, line 139
Contains \Drupal\bootstrap\Utility\StorageItem.

Class

StorageItem
Theme Storage Item.

Namespace

Drupal\bootstrap\Utility

Code

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