function annotationcommand_adapter_discover

master annotationcommand_adapter.inc annotationcommand_adapter_discover($searchpath, $phase = false, $phase_max = false)

Search for annotation commands at the provided search path.

See also

_drush_find_commandfiles()

1 call to annotationcommand_adapter_discover()

File

includes/annotationcommand_adapter.inc, line 90
annotationcommand_adapter.inc

Code

function annotationcommand_adapter_discover($searchpath, $phase = false, $phase_max = false) {
  if (empty($searchpath)) {
    return;
  }
  if (($phase >= DRUSH_BOOTSTRAP_DRUPAL_SITE) && (drush_drupal_major_version() >= 8)) {
    return;
  }
  $annotation_commandfiles =[];
  // Assemble a cid specific to the bootstrap phase and searchpaths.
  // Bump $cf_version when making a change to a dev version of Drush
  // that invalidates the commandfile cache.
  $cf_version = 1;
  $cid = drush_get_cid('annotationfiles-' . $phase, array(), array_merge($searchpath, array($cf_version)));
  $command_cache = drush_cache_get($cid);
  if (isset($command_cache->data)) {
    $annotation_commandfiles = $command_cache->data;
  }
  else {
    // Check to see if this is the Drush searchpath for instances where we are
    // NOT going to do a full bootstrap (e.g. when running a help command)
    if (($phase == DRUSH_BOOTSTRAP_DRUPAL_SITE) && ($phase_max < DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
      $searchpath = annotationcommand_adapter_refine_searchpaths($searchpath);
    }
    $discovery = annotationcommand_adapter_get_discovery();
    $annotation_commandfiles = $discovery->discoverNamespaced($searchpath, '\Drupal');
    drush_cache_set($cid, $annotation_commandfiles);
  }
  drush_set_context('DRUSH_ANNOTATED_COMMANDFILES', array_merge(drush_get_context('DRUSH_ANNOTATED_COMMANDFILES'), $annotation_commandfiles));
}