5 * Definition of Drush\Command\Commandfiles.
8 namespace Drush\Command;
11 * Default commandfiles implementation.
13 * This class manages the list of commandfiles that are active
14 * in Drush for the current command invocation.
16 class Commandfiles implements CommandfilesInterface {
20 function __construct() {
21 $this->cache = array();
22 $this->deferred = array();
30 return $this->deferred;
37 function add($commandfile) {
38 $load_command = FALSE;
40 $module = basename($commandfile);
41 $module = preg_replace('/\.*drush[0-9]*\.inc/', '', $module);
42 $module_versionless = preg_replace('/\.d([0-9]+)$/', '', $module);
43 if (!isset($this->cache[$module_versionless])) {
45 if (preg_match('/\.d([0-9]+)$/', $module, $matches)) {
46 $drupal_version = $matches[1];
48 if (empty($drupal_version)) {
52 if (function_exists('drush_drupal_major_version') && ($drupal_version == drush_drupal_major_version())) {
56 // Signal that we should try again on
57 // the next bootstrap phase.
58 $this->deferred[$module] = $commandfile;
62 $this->cache[$module_versionless] = $commandfile;
63 require_once $commandfile;
64 unset($this->deferred[$module]);