class DrupalCoreRecommendedBuilder
Builder to produce metapackage for drupal/core-recommended.
Hierarchy
- class \Drupal\Composer\Generator\Builder\DrupalPackageBuilder implements \Drupal\Composer\Generator\BuilderInterface- class \Drupal\Composer\Generator\Builder\DrupalCoreRecommendedBuilder extends \Drupal\Composer\Generator\Builder\DrupalPackageBuilder
 
Expanded class hierarchy of DrupalCoreRecommendedBuilder
3 files declare their use of DrupalCoreRecommendedBuilder
- BuilderTest.php in core/tests/ Drupal/ Tests/ Composer/ Generator/ BuilderTest.php 
- MetapackageUpdateTest.php in core/tests/ Drupal/ Tests/ Composer/ Generator/ MetapackageUpdateTest.php 
- PackageGenerator.php in composer/Generator/ PackageGenerator.php 
File
- 
              composer/Generator/ Builder/ DrupalCoreRecommendedBuilder.php, line 10 
Namespace
Drupal\Composer\Generator\BuilderView source
class DrupalCoreRecommendedBuilder extends DrupalPackageBuilder {
  
  /**
   * {@inheritdoc}
   */
  public function getPath() {
    return 'CoreRecommended';
  }
  
  /**
   * {@inheritdoc}
   */
  public function getPackage() {
    $composer = $this->initialPackageMetadata();
    // Pull up the composer lock data.
    $composerLockData = $this->drupalCoreInfo
      ->composerLock();
    if (!isset($composerLockData['packages'])) {
      return $composer;
    }
    // Make a list of packages we do not want to put in the 'require' section.
    $remove_list = [
      'drupal/core',
      'wikimedia/composer-merge-plugin',
      'composer/installers',
      // This package contains no code other than interfaces, so allow sites
      // to use any compatible version without needing to switch off of
      // drupal/core-recommended.
'psr/http-message',
      // sebastian/diff is a PHPUnit dependency with an annual major release
      // cycle. In order to allow supporting multiple PHPUnit major versions,
      // we cannot let it be pinned.
'sebastian/diff',
    ];
    // Copy the 'packages' section from the Composer lock into our 'require'
    // section. There is also a 'packages-dev' section, but we do not need
    // to pin 'require-dev' versions, as 'require-dev' dependencies are never
    // included from subprojects. Use 'drupal/core-dev' to get Drupal's
    // dev dependencies.
    foreach ($composerLockData['packages'] as $package) {
      // If there is no 'source' record, then this is a path repository
      // or something else that we do not want to include.
      if (isset($package['source']) && !in_array($package['name'], $remove_list)) {
        $composer['require'][$package['name']] = '~' . $package['version'];
      }
    }
    return $composer;
  }
  
  /**
   * Returns the initial package metadata that describes the metapackage.
   *
   * @return array
   *   The initial package metadata.
   */
  protected function initialPackageMetadata() {
    return [
      "name" => "drupal/core-recommended",
      "type" => "metapackage",
      "description" => "Core and its dependencies with known-compatible minor versions. Require this project INSTEAD OF drupal/core.",
      "license" => "GPL-2.0-or-later",
      "conflict" => [
        "webflo/drupal-core-strict" => "*",
      ],
      "require" => [
        "drupal/core" => Composer::drupalVersionBranch(),
      ],
    ];
  }
}Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title | 
|---|---|---|---|---|
| DrupalCoreRecommendedBuilder::getPackage | public | function | Generate the Composer.json data for the current tag or branch. | Overrides BuilderInterface::getPackage | 
| DrupalCoreRecommendedBuilder::getPath | public | function | Return the path to where the metapackage should be written. | Overrides BuilderInterface::getPath | 
| DrupalCoreRecommendedBuilder::initialPackageMetadata | protected | function | Returns the initial package metadata that describes the metapackage. | |
| DrupalPackageBuilder::$drupalCoreInfo | protected | property | Information about composer.json, composer.lock etc. in current release. | |
| DrupalPackageBuilder::__construct | public | function | DrupalPackageBuilder constructor. | Overrides BuilderInterface::__construct | 
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
