function DrushMakeProject::download

8.0.x make.project.inc DrushMakeProject::download()
6.x make.project.inc DrushMakeProject::download()
7.x make.project.inc DrushMakeProject::download()
5.x make.project.inc DrushMakeProject::download()
master make.project.inc DrushMakeProject::download()

Download a project.

1 call to DrushMakeProject::download()
DrushMakeProject::make in commands/make/make.project.inc
Build a project.

File

commands/make/make.project.inc, line 103
Drush Make processing classes.

Class

DrushMakeProject
The base project class.

Code

function download() {
  $this->downloaded = TRUE;

  // In some cases, make_download_factory() is going to need to know the
  // full version string of the project we're trying to download. However,
  // the version is a project-level attribute, not a download-level
  // attribute. So, if we don't already have a full version string in the
  // download array (e.g. if it was initialized via the release history XML
  // for the PM case), we take the version info from the project-level
  // attribute, convert it into a full version string, and stuff it into
  // $this->download so that the download backend has access to it, too.
  if (!empty($this->version) && empty($this->download['full_version'])) {
    $full_version = '';
    $matches = array();
    // Core needs different conversion rules than contrib.
    if (!empty($this->type) && $this->type == 'core') {
      // Generally, the version for core is already set properly.
      $full_version = $this->version;
      // However, it might just be something like '7' or '7.x', in which
      // case we need to turn that into '7.x-dev';
      if (preg_match('/^\d+(\.x)?$/', $this->version, $matches)) {
        // If there's no '.x' already, append it.
        if (empty($matches[1])) {
          $full_version .= '.x';
        }
        $full_version .= '-dev';
      }
    }
    // Contrib.
    else {
      // If the version doesn't already define a core version, prepend it.
      if (!preg_match('/^\d+\.x-\d+.*$/', $this->version)) {
        // Just find the major version from $this->core so we don't end up
        // with version strings like '7.12-2.0'.
        $core_parts = explode('.', $this->core);
        $full_version = $core_parts[0] . '.x-';
      }
      $full_version .= $this->version;
      // If the project-level version attribute is just a number it's a major
      // version.
      if (preg_match('/^\d+(\.x)?$/', $this->version, $matches)) {
        // If there's no '.x' already, append it.
        if (empty($matches[1])) {
          $full_version .= '.x';
        }
        $full_version .= '-dev';
      }
    }
    $this->download['full_version'] = $full_version;
  }

  if (make_download_factory($this->name, $this->type, $this->download, $this->download_location) === FALSE) {
    $this->downloaded = FALSE;
  }
  return $this->downloaded;
}