function drush_get_engines

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

Return a structured array of engines of a specific type from commandfiles implementing hook_drush_engine_$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/wget.inc" exists and a specific path is not provided.

Parameters

$type: The type of engine.

Return value

A structured array of engines.

4 calls to drush_get_engines()
drush_include_engine in includes/drush.inc
Include the engine code for a specific named engine of a certain type.
drush_pm_include_version_control in commands/pm/pm.drush.inc
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_print_help in includes/drush.inc
Print the help for a single command to the screen.
drush_version_control_reserved_files in includes/drush.inc
Return a list of VCSs reserved files and directories.

File

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

Code

function drush_get_engines($type) {
  $engines = array();
  $list = drush_commandfile_list();
  foreach ($list as $commandfile => $path) {
    if (drush_command_hook($commandfile, 'drush_engine_' . $type)) {
      $function = $commandfile . '_drush_engine_' . $type;
      $result = $function();
      foreach ((array) $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), $type),
        );
        $engines[$key] = $engine;
      }
    }
  }
  return $engines;
}