function drush_get_class

8.0.x drush_get_class($class_name, $constructor_args = array(), $variations = array())
6.x drush_get_class($class_name, $constructor_args, $class_dir = NULL)
7.x drush_get_class($class_name, $constructor_args = array(), $variations = array())
master drush_get_class($class_name, $constructor_args = array(), $variations = array())
8 calls to drush_get_class()
drush_include_engine in includes/
Include the engine code for a specific named engine of a certain type.
drush_migrate_manifest_get_class in commands/core/
Get a version specific MigrateManifest class.
drush_queue_get_class in commands/core/
Return the appropriate queue class.
drush_role_get_class in commands/core/
Get core version specific Role handler class.
drush_sql_get_class in commands/sql/
Wrapper for drush_get_class; instantiates an driver-specific instance of SqlBase class.

... See full list


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


function drush_get_class($class_name, $constructor_args = array(), $variations = array()) {
  if (empty($variations)) {
    $variations[] = drush_drupal_major_version();
  $class_names = is_array($class_name) ? $class_name : array($class_name);
  foreach ($class_names as $class_name) {
    for ($i = count($variations); $i >= 0; $i--) {
      $variant_class_name = $class_name . implode('', array_slice($variations, 0, $i));
      if (class_exists($variant_class_name)) {
        $reflectionClass = new ReflectionClass($variant_class_name);
        return !empty($constructor_args) ? $reflectionClass->newInstanceArgs($constructor_args) : $reflectionClass->newInstanceArgs();
  // Something bad happenned. TODO Exception?
  return drush_set_error('DRUSH_GET_CLASS_ERROR', dt('Unable to load class !class', array('!class' => $class_name)));