/** * Class constructor. * * @param CommandBase $command * The current instance of the command. */ public function __construct(CommandBase $command) { $this->command = $command; // Determine if the "path" option has been set. $this->path = drush_get_option('path'); if ($this->path && !file_exists($this->path)) { return drush_set_error('DRUSH_LWG_INVALID_PATH', dt("The specified project path does not exist:\n!path", array('!path' => $this->path))); } else { if (!$this->path) { $this->path = drush_cwd(); } } // Ensure the path is writable. if (!is_writable($this->path)) { return drush_set_error('DRUSH_LWG_PATH_NOT_WRITABLE', dt("The specified project path is not writable:\n!path", array('!path' => $this->path))); } foreach (drush_scan_directory($this->path, '/\\.info(\\.yml)?/') as $file) { if ($this->info = drush_drupal_parse_info_file($file->filename)) { $this->name = $file->name; break; } } if (!$this->getInfo('name')) { return drush_set_error('DRUSH_LWG_NOT_PROJECT', dt('Project info not found. Please navigate to a valid project directory or specify one with the --path option.')); } // Indicate that this is a valid project. $this->valid = TRUE; }
public function isActiveProjectDir() { $contents = drush_scan_directory($this->getProjectDir(), '/.*/', array('.', '..'), 0, FALSE, 'basename', 0, FALSE); if (!empty($contents)) { return TRUE; } return FALSE; }
/** * Find and load environment definitions. */ private function findEnvironments() { foreach ($this->configPaths as $path) { foreach (drush_scan_directory($path, '/env\\.drushrc\\.y(a)?ml/') as $file) { $this->loadEnvFile($file); } } }
function isEmpty() { $files = drush_scan_directory($dir, "//", array('.', '..')); return empty($files); }
/** * Check for any contents of the destination folder. * * @return bool * Whether the dir is empty. */ public function dirIsEmpty($subdir = NULL) { $path = $subdir ? "{$this->dir}/{$subdir}" : $this->dir; return count(drush_scan_directory($path, '/.*/')) == 0; }