class Commandfiles
- 8.0.x lib/Drush/Command/Commandfiles.php Commandfiles
- 7.x lib/Drush/Command/Commandfiles.php Commandfiles
- master lib/Drush/Command/Commandfiles.php Commandfiles
Default commandfiles implementation.
This class manages the list of commandfiles that are active in Drush for the current command invocation.
Namespace
Drush\CommandHierarchy
- class Commandfiles implements CommandfilesInterface
Expanded class hierarchy of Commandfiles
Members
Name![]() |
Modifiers | Type | Description |
---|---|---|---|
Commandfiles::$cache | protected | property | |
Commandfiles::$deferred | protected | property | |
Commandfiles::add | function | Overrides CommandfilesInterface::add | |
Commandfiles::deferred | function | Overrides CommandfilesInterface::deferred | |
Commandfiles::get | function | Overrides CommandfilesInterface::get | |
Commandfiles::sort | function | Overrides CommandfilesInterface::sort | |
Commandfiles::__construct | function |
File
- lib/
Drush/ Command/ Commandfiles.php, line 16 - Definition of Drush\Command\Commandfiles.
View source
class Commandfiles implements CommandfilesInterface {
protected $cache;
protected $deferred;
function __construct() {
$this->cache = array();
$this->deferred = array();
}
function get() {
return $this->cache;
}
function deferred() {
return $this->deferred;
}
function sort() {
ksort($this->cache);
}
function add($commandfile) {
$load_command = FALSE;
$module = basename($commandfile);
$module = preg_replace('/\.*drush[0-9]*\.inc/', '', $module);
$module_versionless = preg_replace('/\.d([0-9]+)$/', '', $module);
if (!isset($this->cache[$module_versionless])) {
$drupal_version = '';
if (preg_match('/\.d([0-9]+)$/', $module, $matches)) {
$drupal_version = $matches[1];
}
if (empty($drupal_version)) {
$load_command = TRUE;
}
else {
if (function_exists('drush_drupal_major_version') && ($drupal_version == drush_drupal_major_version())) {
$load_command = TRUE;
}
else {
// Signal that we should try again on
// the next bootstrap phase.
$this->deferred[$module] = $commandfile;
}
}
if ($load_command) {
$this->cache[$module_versionless] = $commandfile;
require_once $commandfile;
unset($this->deferred[$module]);
}
}
return $load_command;
}
}