SharedTempStore::setIfNotExists

public SharedTempStore::setIfNotExists($key, $value)

Stores a particular key/value pair only if the key doesn't already exist.

Parameters

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

mixed $value: The data to store.

Return value

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

File

core/modules/user/src/SharedTempStore.php, line 144

Class

SharedTempStore
Stores and retrieves temporary data for a given owner.

Namespace

Drupal\user

Code

public function setIfNotExists($key, $value) {
  $value = (object) array(
    'owner' => $this->owner,
    'data' => $value,
    'updated' => (int) $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'),
  );
  return $this->storage->setWithExpireIfNotExists($key, $value, $this->expire);
}
doc_Drupal
2016-10-29 09:42:18
Comments
Leave a Comment

Please login to continue.