function drush_config_get_object

8.0.x config.drush.inc drush_config_get_object($config_name)
7.x config.drush.inc drush_config_get_object($config_name)
master config.drush.inc drush_config_get_object($config_name)

Show and return a config object

Parameters

$config_name: The config object name.

1 call to drush_config_get_object()
drush_config_get in commands/core/config.drush.inc
Config get command callback.

File

commands/core/config.drush.inc, line 822
Provides Configuration Management commands.

Code

function drush_config_get_object($config_name) {
  $source = drush_get_option('source', 'active');
  $include_overridden = drush_get_option('include-overridden', FALSE);

  if ($include_overridden) {
    // Displaying overrides only applies to active storage.
    $config = \Drupal::config($config_name);
    $data = $config->get();
  }
  elseif ($source == 'active') {
    $config = \Drupal::service('config.storage');
    $data = $config->read($config_name);
  }
  elseif ($source == 'sync') {
    $config = \Drupal::service('config.storage.sync');
    $data = $config->read($config_name);
  }
  else {
    return drush_set_error(dt('Unknown value !value for config source.', array('!value' => $source)));
  }

  if ($data === FALSE) {
    return drush_set_error(dt('Config !name does not exist in !source configuration.', array('!name' => $config_name, '!source' => $source)));
  }
  if (empty($data)) {
    drush_log(dt('Config !name exists but has no data.', array('!name' => $config_name)), LogLevel::NOTICE);
    return;
  }
  return $data;
}