protected function buildProject(array $package) {
    $info = [];

    switch ($package['type']) {
      case 'drupal-core':
      case 'drupal-theme':
      case 'drupal-module':
        $info['type'] = substr($package['type'], 7);
        break;
    }
    $info += $this->buildPackage($package);

    // Core should always use git branch + revision, or patches won't apply
    // correctly.
    if ($package['type'] === 'drupal-core') {
      // Composer downloads core from its subtree split on GitHub, but the
      // packaging system will choke on that.
      $info['download']['url'] = 'https://git.drupal.org/project/drupal.git';
      // Derive the branch from the version string.
      $info['download']['branch'] = preg_replace(
        // 8.4.2 --> 8.4.x
        // 8.6.0-beta2 --> 8.6.x
        ['/\.\d(-\w+\d+)?$/', '/-dev$/'],
        // 8.5.x-dev --> 8.5.x
        ['.x', NULL],
        $package['version']
      );

      // We never want to specify a commit hash, regardless of whether this is
      // a dev branch or tagged release.
      unset($info['download']['revision']);

      // But, if it is a tagged release (i.e., there's no -dev suffix in the
      // version), we do want to specify that tag.
      if (strpos($package['version'], '-dev') === FALSE) {
        $info['download']['tag'] = $package['version'];
      }
    }
    // Dev versions should use git branch + revision, otherwise a tag is used.
    elseif (strstr($package['version'], 'dev')) {
      // 'dev-' prefix indicates a branch-alias. Stripping the dev prefix from
      // the branch name is sufficient.
      // @see https://getcomposer.org/doc/articles/aliases.md
      if (strpos($package['version'], 'dev-') === 0) {
        $info['download']['branch'] = substr($package['version'], 4);
      }
      // Otherwise, leave as is. Version may already use '-dev' suffix.
      else {
        $info['download']['branch'] = $package['version'];
      }
      $info['download']['revision'] = $package['source']['reference'];
    }
    // Any other type of package can use a standard Drupal version number.
    else {
      // Drupalize the tag versioning, e.g. 8.1.0-alpha1 => 8.x-1.0-alpha1.
      $version = sprintf(
        '%d.x-%s',
        $package['version']{0},
        substr($package['version'], 2)
      );
      // Make the version Drush make-compatible: 1.x-13.0-beta2 --> 1.13-beta2
      $info['version'] = preg_replace(
        '/^([0-9]+)\.x-([0-9]+)\.[0-9]+(-.+)?/',
        '$1.$2$3',
        $version
      );
      unset($info['download']);
    }
    return $info;
  }
protected function buildProject(array $package) {
    $info = [];

    switch ($package['type']) {
      case 'drupal-core':
      case 'drupal-theme':
      case 'drupal-module':
        $info['type'] = substr($package['type'], 7);
        break;
    }
    $info += $this->buildPackage($package);

    // Core should always use git branch + revision, or patches won't apply
    // correctly.
    if ($package['type'] === 'drupal-core') {
      // Composer downloads core from its subtree split on GitHub, but the
      // packaging system will choke on that.
      $info['download']['url'] = 'https://git.drupal.org/project/drupal.git';
      // Derive the branch from the version string.
      $info['download']['branch'] = preg_replace(
        // 8.4.2 --> 8.4.x
        // 8.6.0-beta2 --> 8.6.x
        ['/\.\d(-\w+\d+)?$/', '/-dev$/'],
        // 8.5.x-dev --> 8.5.x
        ['.x', NULL],
        $package['version']
      );

      // We never want to specify a commit hash, regardless of whether this is
      // a dev branch or tagged release.
      unset($info['download']['revision']);

      // But, if it is a tagged release (i.e., there's no -dev suffix in the
      // version), we do want to specify that tag.
      if (strpos($package['version'], '-dev') === FALSE) {
        $info['download']['tag'] = $package['version'];
      }
    }
    // Dev versions should use git branch + revision, otherwise a tag is used.
    elseif (strstr($package['version'], 'dev')) {
      // 'dev-' prefix indicates a branch-alias. Stripping the dev prefix from
      // the branch name is sufficient.
      // @see https://getcomposer.org/doc/articles/aliases.md
      if (strpos($package['version'], 'dev-') === 0) {
        $info['download']['branch'] = substr($package['version'], 4);
      }
      // Otherwise, leave as is. Version may already use '-dev' suffix.
      else {
        $info['download']['branch'] = $package['version'];
      }
      $info['download']['revision'] = $package['source']['reference'];
    }
    // Any other type of package can use a standard Drupal version number.
    else {
      // Drupalize the tag versioning, e.g. 8.1.0-alpha1 => 8.x-1.0-alpha1.
      $version = sprintf(
        '%d.x-%s',
        $package['version']{0},
        substr($package['version'], 2)
      );
      // Make the version Drush make-compatible: 1.x-13.0-beta2 --> 1.13-beta2
      $info['version'] = preg_replace(
        '/^([0-9]+)\.x-([0-9]+)\.[0-9]+(-.+)?/',
        '$1.$2$3',
        $version
      );
      unset($info['download']);
    }
    return $info;
  }
protected function buildProject ( array $ package ) { $ info = [ ] ; switch ( $ package [ 'type' ] ) { case 'drupal-core' : case 'drupal-theme' : case 'drupal-module' : $ info [ 'type' ] = substr ( $ package [ 'type' ] , 7 ) ; break ; } $ info += $ this -> buildPackage ( $ package ) ; // Core should always use git branch + revision, or patches won't apply // correctly. if ( $ package [ 'type' ] === 'drupal-core' ) { // Composer downloads core from its subtree split on GitHub, but the // packaging system will choke on that. $ info [ 'download' ] [ 'url' ] = 'https://git.drupal.org/project/drupal.git' ; // Derive the branch from the version string. $ info [ 'download' ] [ 'branch' ] = preg_replace ( // 8.4.2 --> 8.4.x // 8.6.0-beta2 --> 8.6.x [ '/\.\d(-\w+\d+)?$/' , '/-dev$/' ] , // 8.5.x-dev --> 8.5.x [ '.x' , NULL ] , $ package [ 'version' ] ) ; // We never want to specify a commit hash, regardless of whether this is // a dev branch or tagged release. unset ( $ info [ 'download' ] [ 'revision' ] ) ; // But, if it is a tagged release (i.e., there's no -dev suffix in the // version), we do want to specify that tag. if ( strpos ( $ package [ 'version' ] , '-dev' ) === FALSE ) { $ info [ 'download' ] [ 'tag' ] = $ package [ 'version' ] ; } } // Dev versions should use git branch + revision, otherwise a tag is used. elseif ( strstr ( $ package [ 'version' ] , 'dev' ) ) { // 'dev-' prefix indicates a branch-alias. Stripping the dev prefix from // the branch name is sufficient. // @see https://getcomposer.org/doc/articles/aliases.md if ( strpos ( $ package [ 'version' ] , 'dev-' ) === 0 ) { $ info [ 'download' ] [ 'branch' ] = substr ( $ package [ 'version' ] , 4 ) ; } // Otherwise, leave as is. Version may already use '-dev' suffix. else { $ info [ 'download' ] [ 'branch' ] = $ package [ 'version' ] ; } $ info [ 'download' ] [ 'revision' ] = $ package [ 'source' ] [ 'reference' ] ; } // Any other type of package can use a standard Drupal version number. else { // Drupalize the tag versioning, e.g. 8.1.0-alpha1 => 8.x-1.0-alpha1. $ version = sprintf ( '%d.x-%s' , $ package [ 'version' ] { 0 } , substr ( $ package [ 'version' ] , 2 ) ) ; // Make the version Drush make-compatible: 1.x-13.0-beta2 --> 1.13-beta2 $ info [ 'version' ] = preg_replace ( '/^([0-9]+)\.x-([0-9]+)\.[0-9]+(-.+)?/' , '$1.$2$3' , $ version ) ; unset ( $ info [ 'download' ] ) ; } return $ info ; }
Builds a make structure for a Drupal module, theme, profile, or core.

@param array $package
The Composer package definition.

@return array
The generated make structure.
Builds a make structure for a Drupal module theme profile or core .