function _drush_config_file

8.0.x context.inc _drush_config_file($context, $prefix = NULL, $version = '')
6.x context.inc _drush_config_file($context, $prefix = NULL, $version = '')
7.x context.inc _drush_config_file($context, $prefix = NULL, $version = '')
3.x context.inc _drush_config_file($context)
4.x context.inc _drush_config_file($context, $prefix = NULL, $version = '')
5.x context.inc _drush_config_file($context, $prefix = NULL, $version = '')
master context.inc _drush_config_file($context, $prefix = NULL, $version = '')

Return a list of possible drushrc file locations.

@context A valid drush context from drush_context_names(). @prefix Optional. Specify a prefix to prepend to ".drushrc.php" when looking for config files. Most likely used by contrib commands.

Return value

An associative array containing possible config files to load The keys are the 'context' of the files, the values are the file system locations.

2 calls to _drush_config_file()
drush_load_config in includes/context.inc
Load drushrc files (if available) from several possible locations.
drush_save_config in includes/context.inc
Save the settings in a specific context to the applicable configuration file This is useful is you want certain settings to be available automatically the next time a command is executed.

File

includes/context.inc, line 98
The Drush context API implementation.

Code

function _drush_config_file($context, $prefix = NULL, $version = '') {
  $configs = array();
  $base_name = 'drush' . $version . 'rc.php';
  $config_file = $prefix ? $prefix . '.' . $base_name : $base_name;

  // Did the user explicitly specify a config file?
  if ($config_list = (array) drush_get_context('DRUSH_CONFIG')) {
    foreach ($config_list as $config) {
      if (is_dir($config)) {
        $config = $config . '/' . $config_file;
      }
      $configs['custom'][] = $config;
    }
  }

  if ($drupal_root = \Drush::bootstrapManager()->getRoot()) {
    $configs['drupal'] = array(
      $drupal_root . '/../drush/' . $config_file,
      $drupal_root . '/sites/all/drush/' . $config_file,
      $drupal_root . '/drush/' . $config_file,
    );

    if ($conf_path = drush_get_context('DRUSH_SELECTED_DRUPAL_SITE_CONF_PATH', 'sites/default')) {
      $site_path = $drupal_root . '/' . $conf_path;
      $configs['site'] = $site_path . "/" . $config_file;
    }
  }

  // in the user home directory
  $server_home = drush_server_home();
  if (isset($server_home)) {
    $configs['user'] = $server_home . '/.' . $config_file;
  }

  // in $HOME/.drush directory
  $per_user_config_dir = drush_get_context('DRUSH_PER_USER_CONFIGURATION');
  if (!empty($per_user_config_dir)) {
    $configs['home.drush'] = $per_user_config_dir . '/' . $config_file;
  }

  // In the system wide configuration folder.
  $configs['system'] = drush_get_context('DRUSH_SITE_WIDE_CONFIGURATION') . '/' . $config_file;

  return empty($configs[$context]) ? '' : $configs[$context];
}