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.

Parameters

string $type: Engine type.

string $engine: Engine name.

array $config: Engine configuration. Tipically it comes from a command declaration.

Return value

TRUE or instanced object of available class on success. FALSE on fail.

8 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_make_convert in commands/make/make.drush.inc
Command callback; convert ini makefile to YAML.
drush_outputformat_list::validate in commands/core/outputformat/list.inc

... See full list

File

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

Code

function drush_load_engine($type, $engine, $config = array()) {
  $engine_info = drush_get_engines($type);
  $engine = drush_select_engine($config, $engine_info, $engine);
  $config['engine-info'] = $engine_info['engines'][$engine];

  // Check engine dependency on drupal modules before include.
  $dependencies = $config['engine-info']['drupal dependencies'];
  foreach ($dependencies as $dependency) {
    if (!drush_module_exists($dependency)) {
      return drush_set_error('DRUSH_ENGINE_DEPENDENCY_ERROR', dt('!engine_type: !engine engine needs the following modules installed/enabled to run: !dependencies.', array('!engine_type' => $type, '!engine' => $engine, '!dependencies' => implode(', ', $dependencies))));
    }
  }

  $result = drush_include_engine($type, $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;
}