function annotationcommand_adapter_create_commandfile_instance

master annotationcommand_adapter.inc annotationcommand_adapter_create_commandfile_instance($commandfile_path, $commandfile_class)

Create and cache a commandfile instance.

Parameters

string $commandfile_path Path to the commandfile implementation:

string $commandfile_class Namespace and class of the commandfile object:

Return value

object

1 call to annotationcommand_adapter_create_commandfile_instance()
annotationcommand_adapter_get_commands in includes/annotationcommand_adapter.inc
Internal function called by annotationcommand_adapter_commands, which is called by drush_get_commands().

File

includes/annotationcommand_adapter.inc, line 264
annotationcommand_adapter.inc

Code

function annotationcommand_adapter_create_commandfile_instance($commandfile_path, $commandfile_class) {
  $runner = \Drush::runner();
  $app = \Drush::service('application');
  $cache = &drush_get_context('DRUSH_ANNOTATION_COMMANDFILE_INSTANCES');
  if (!isset($cache[$commandfile_path])) {
    include_once $commandfile_path;
    $commandhandler = $runner->registerCommandClass($app, $commandfile_class);
    $cache[$commandfile_path] = $commandhandler;
  }
  return $cache[$commandfile_path];
}