function drush_load_engine

8.0.x engines.inc drush_load_engine($type, $engine, $config = array())
6.x engines.inc drush_load_engine($type, $engine, $version = NULL, $path = NULL, $engine_config = NULL)
7.x engines.inc drush_load_engine($type, $engine, $config = array())
master engines.inc drush_load_engine($type, $engine, $config = array())

Loads and validate an engine of the given type.

6 calls to drush_load_engine()
drush_format in includes/output.inc
Prepares a variable for printing. Loads the requested output formatter and uses it to process the provided input.
drush_handle_command_output in includes/command.inc
Convert the structured output array provided from the Drush command into formatted output. Output is only printed for commands that define 'default-format' &/or 'default-pipe-format'; all other commands are expected to do…
drush_load_command_engine in includes/engines.inc
Selects and loads an engine implementing the given type.
drush_outputformat_list::validate in commands/core/outputformat/list.inc
drush_outputformat_variables::validate in commands/core/outputformat/variables.inc

... See full list

File

includes/engines.inc, line 419
The drush engines API implementation and helpers.

Code

function drush_load_engine($type, $engine, $version = NULL, $path = NULL, $engine_config = NULL) {
  $engine_info = drush_get_engines($type);
  $selected_engine = drush_find_engine_to_use($engine_config, $engine_info, $engine);
  if (!array_key_exists($selected_engine, $engine_info['engines'])) {
    return drush_set_error('DRUSH_UNKNOWN_ENGINE_TYPE', dt('Unknown !engine_type engine !engine', array('!engine' => $selected_engine, '!engine_type' => $type)));
  }

  $result = drush_include_engine($type, $selected_engine, $version, $path, $engine_config);
  if (is_object($result)) {
    $valid = method_exists($result, 'validate') ? $result->validate() : TRUE;
    if ($valid) {
      drush_set_engine($type, $result);
    }
  }
  else {
    $function = strtr($type, '-', '_') . '_validate';
    $valid = function_exists($function) ? call_user_func($function) : TRUE;
  }
  if (!$valid) {
    return FALSE;
  }
  return $result;
}