src/Update/DoPackagistConverter.php
public static function convertComposerJson($composer_json) {
    // Update version constraints in require.
    foreach ($composer_json['require'] as $package_name => $version_constraint) {
      if ($package_name == 'drupal/core') {
        continue;
      }
      if (strstr($package_name, 'drupal/')) {
        $composer_json['require'][$package_name] = self::convertVersionConstraint($version_constraint);
      }
    }

    // Change drupal/lightning to acquia/lightning.
    $composer_json['require']['acquia/lightning'] = '^2';
    unset($composer_json['require']['drupal/lightning']);

    // Update version constraints in require-dev.
    foreach ($composer_json['require-dev'] as $package_name => $version_constraint) {
      if (strstr($package_name, 'drupal/')) {
        $composer_json['require-dev'][$package_name] = self::convertVersionConstraint($version_constraint);
      }
    }

    // Remove https://packagist.drupal-composer.org.
    foreach ($composer_json['repositories'] as $key => $repository) {
      if ($repository['url'] == 'https://packagist.drupal-composer.org') {
        unset($composer_json['repositories'][$key]);
      }
    }

    // Add https://packages.drupal.org/8.
    $composer_json['repositories']['drupal'] = [
      'type' => 'composer',
      'url' => 'https://packages.drupal.org/8',
    ];

    return $composer_json;
  }
public static function convertComposerJson($composer_json) {
    // Update version constraints in require.
    foreach ($composer_json['require'] as $package_name => $version_constraint) {
      if ($package_name == 'drupal/core') {
        continue;
      }
      if (strstr($package_name, 'drupal/')) {
        $composer_json['require'][$package_name] = self::convertVersionConstraint($version_constraint);
      }
    }

    // Change drupal/lightning to acquia/lightning.
    $composer_json['require']['acquia/lightning'] = '^2';
    unset($composer_json['require']['drupal/lightning']);

    // Update version constraints in require-dev.
    foreach ($composer_json['require-dev'] as $package_name => $version_constraint) {
      if (strstr($package_name, 'drupal/')) {
        $composer_json['require-dev'][$package_name] = self::convertVersionConstraint($version_constraint);
      }
    }

    // Remove https://packagist.drupal-composer.org.
    foreach ($composer_json['repositories'] as $key => $repository) {
      if ($repository['url'] == 'https://packagist.drupal-composer.org') {
        unset($composer_json['repositories'][$key]);
      }
    }

    // Add https://packages.drupal.org/8.
    $composer_json['repositories']['drupal'] = [
      'type' => 'composer',
      'url' => 'https://packages.drupal.org/8',
    ];

    return $composer_json;
  }
public static function convertComposerJson ( $ composer_json ) { // Update version constraints in require. foreach ( $ composer_json [ 'require' ] as $ package_name => $ version_constraint ) { if ( $ package_name == 'drupal/core' ) { continue ; } if ( strstr ( $ package_name , 'drupal/' ) ) { $ composer_json [ 'require' ] [ $ package_name ] = self :: convertVersionConstraint ( $ version_constraint ) ; } } // Change drupal/lightning to acquia/lightning. $ composer_json [ 'require' ] [ 'acquia/lightning' ] = '^2' ; unset ( $ composer_json [ 'require' ] [ 'drupal/lightning' ] ) ; // Update version constraints in require-dev. foreach ( $ composer_json [ 'require-dev' ] as $ package_name => $ version_constraint ) { if ( strstr ( $ package_name , 'drupal/' ) ) { $ composer_json [ 'require-dev' ] [ $ package_name ] = self :: convertVersionConstraint ( $ version_constraint ) ; } } // Remove https://packagist.drupal-composer.org. foreach ( $ composer_json [ 'repositories' ] as $ key => $ repository ) { if ( $ repository [ 'url' ] == 'https://packagist.drupal-composer.org' ) { unset ( $ composer_json [ 'repositories' ] [ $ key ] ) ; } } // Add https://packages.drupal.org/8. $ composer_json [ 'repositories' ] [ 'drupal' ] = [ 'type' => 'composer' , 'url' => 'https://packages.drupal.org/8' , ] ; return $ composer_json ; }
Converts composer.json from packagist.drupal-composer.org to D.O format.

@param array $composer_json
The composer.json array.

@return array
The modified composer.json array.
Converts composer . json from packagist . drupal - composer . org to D . O format .