function drush_state_set

8.0.x state.drush.inc drush_state_set($key = NULL, $value = NULL)
7.x state.drush.inc drush_state_set($key = NULL, $data = NULL)

State set command callback.

Parameters

$key: The config key.

$data: The data to save to config.

File

commands/core/state.drush.inc, line 101
Provides State commands.

Code

function drush_state_set($key = NULL, $data = NULL) {
  // This hidden option is a convenient way to pass a value without passing a key.
  $data = drush_get_option('value', $data);

  if (!isset($data)) {
    return drush_set_error('DRUSH_STATE_ERROR', dt('No state value specified.'));
  }

  // Special flag indicating that the value has been passed via STDIN.
  if ($data === '-') {
    $data = stream_get_contents(STDIN);
  }

  \Drupal::state()->set($key, $data);
}