You are here

public function State::setKeyValue in Key 8

Sets the value of a key.

Parameters

\Drupal\key\KeyInterface $key: The key whose value will be set.

string $key_value: The key value.

Return value

bool TRUE if successful, FALSE if unsuccessful.

Overrides KeyProviderSettableValueInterface::setKeyValue

File

tests/modules/key_test/src/Plugin/KeyProvider/State.php, line 65

Class

State
Defines a key provider that stores in memory.

Namespace

Drupal\key_test\Plugin\KeyProvider

Code

public function setKeyValue(KeyInterface $key, $key_value) {
  return $this->state
    ->set('key_test:' . $this->configuration['state_key'], $key_value);
}