function drush_get_engines

8.0.x drush_get_engines($engine_type)
6.x drush_get_engines($engine_type)
7.x drush_get_engines($engine_type)
3.x drush_get_engines($type)
4.x drush_get_engines($type)
5.x drush_get_engines($engine_type)
master drush_get_engines($engine_type)

Return a structured array of engines of a specific type.

Engines are pluggable subsystems. Each engine of a specific type will implement the same set of API functions and perform the same high-level task using a different backend or approach.

This function/hook is useful when you have a selection of several mutually exclusive options to present to a user to select from.

Other commands are able to extend this list and provide their own engines. The hook can return useful information to help users decide which engine they need, such as description or list of available engine options.

The engine path element will automatically default to a subdirectory (within the directory of the commandfile that implemented the hook) with the name of the type of engine - e.g. an engine "wget" of type "handler" provided by the "pm" commandfile would automatically be found if the file "pm/handler/" exists and a specific path is not provided.


$engine_type: The type of engine.

Return value

A structured array of engines.

5 calls to drush_get_engines()
drush_include_engine in includes/
Include the engine code for a specific named engine of a certain type.
drush_pm_include_version_control in commands/pm/
A simple factory function that tests for version control systems, in a user specified order, and return the one that appears to be appropriate for a specific directory.
drush_version_control_reserved_files in includes/
Return a list of VCSs reserved files and directories.
_drush_load_command_engines in includes/
Include, instantiate and validate command engines.
_drush_merge_engine_data in includes/
Add command structure info from each engine back into the command.


includes/, line 125
The drush API implementation and helpers.


function drush_get_engines($engine_type) {
  $info = drush_get_engine_types_info();
  if (!isset($info[$engine_type])) {
    return drush_set_error('DRUSH_UNKNOWN_ENGINE_TYPE', dt('Unknown engine type !engine_type', array('!engine_type' => $engine_type)));

  $engines = array(
    'info' => $info[$engine_type],
    'engines' => array(),
  $list = drush_commandfile_list();
  $hook = 'drush_engine_' . $engine_type;
  foreach ($list as $commandfile => $path) {
    if (drush_command_hook($commandfile, $hook)) {
      $function = $commandfile . '_' . $hook;
      $result = $function();
      foreach ($result as $key => $engine) {
        // Add some defaults
        $engine += array(
          'commandfile' => $commandfile,
          // Engines by default live in a subdirectory of the commandfile that
          // declared them, named as per the type of engine they are.
          'path' => sprintf("%s/%s", dirname($path), $engine_type),
        $engines['engines'][$key] = $engine;
  return $engines;