function drush_set_config_special_contexts

8.0.x context.inc drush_set_config_special_contexts(&$options)
6.x context.inc drush_set_config_special_contexts(&$options)
7.x context.inc drush_set_config_special_contexts(&$options)
3.x context.inc drush_set_config_special_contexts(&$options)
4.x context.inc drush_set_config_special_contexts(&$options)
5.x context.inc drush_set_config_special_contexts(&$options)
master context.inc drush_set_config_special_contexts(&$options)

There are certain options such as 'site-aliases' and 'command-specific' that must be merged together if defined in multiple drush configuration files. If we did not do this merge, then the last configuration file that defined any of these properties would overwrite all of the options that came before in previously-loaded configuration files. We place all of them into their own context so that this does not happen.

5 calls to drush_set_config_special_contexts()
drush_parse_args in includes/command.inc
Parse console arguments.
drush_set_config_options in includes/context.inc
drush_sitealias_load_all in includes/sitealias.inc
Load every alias file that can be found anywhere in the alias search path.
_drush_sitealias_find_and_load_alias_from_file in includes/sitealias.inc
_drush_sitealias_load_alias in includes/sitealias.inc
Check and see if an alias definition for $alias is available. If it is, load it into the list of aliases cached in the 'site-aliases' context.

File

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

Code

function drush_set_config_special_contexts(&$options) {
  if (isset($options) && is_array($options)) {
    $has_command_specific = array_key_exists('command-specific', $options);
    // Change the keys of the site aliases from 'alias' to '@alias'
    if (array_key_exists('site-aliases', $options)) {
      $user_aliases = $options['site-aliases'];
      $options['site-aliases'] = array();
      foreach ($user_aliases as $alias_name => $alias_value) {
        if (substr($alias_name, 0, 1) != '@') {
          $alias_name = "@$alias_name";
        }
        $options['site-aliases'][$alias_name] = $alias_value;
      }
    }
    // Expand -s into --simulate, etc.
    drush_expand_short_form_options($options);

    foreach (drush_get_global_options() as $name => $info) {
      if (is_array($info)) {
        // For any global option with the 'merge-pathlist' or 'merge-associative' flag, set its
        // value in the specified context.  The option is 'merged' because we
        // load $options with the value from the context prior to including the
        // configuration file.  If the configuration file sets $option['special'][] = 'value',
        // then the configuration will be merged.  $option['special'] = array(...), on the
        // other hand, will replace rather than merge the values together.
        if ((array_key_exists($name, $options)) && (array_key_exists('merge', $info) || (array_key_exists('merge-pathlist', $info) || array_key_exists('merge-associative', $info)))) {
          $context = array_key_exists('context', $info) ? $info['context'] : $name;
          $cache = &drush_get_context($context);
          $value = $options[$name];
          if (!is_array($value) && array_key_exists('merge-pathlist', $info)) {
            $value = explode(PATH_SEPARATOR, $value);
          }
          if (array_key_exists('merge-associative', $info)) {
            foreach ($value as $subkey => $subvalue) {
              $cache[$subkey] = array_merge(isset($cache[$subkey]) ? $cache[$subkey] : array(), $subvalue);
            }
          }
          else {
            $cache = array_unique(array_merge($cache, $value));
          }
          // Once we have moved the option to its special context, we
          // can remove it from its option context -- unless 'propagate-cli-value'
          // is set, in which case we need to let it stick around in options
          // in case it is needed in backend invoke.
          if (!array_key_exists('propagate-cli-value', $info)) {
            unset($options[$name]);
          }
        }
      }
    }

    // If command-specific options were set and if we already have
    // a command, then apply the command-specific options immediately.
    if ($has_command_specific) {
      drush_command_default_options();
    }
  }
}