protected function PackageGenerator::generateMetapackage in Drupal 9
Same name and namespace in other branches
- 8 composer/Generator/PackageGenerator.php \Drupal\Composer\Generator\PackageGenerator::generateMetapackage()
- 10 composer/Generator/PackageGenerator.php \Drupal\Composer\Generator\PackageGenerator::generateMetapackage()
Generate one metapackage.
Parameters
\Composer\IO\IOInterface $io: Composer IO object for interacting with the user.
BuilderInterface $builder: An object that can build a metapackage.
Return value
bool TRUE if the generated metapackage is different than what is on disk.
1 call to PackageGenerator::generateMetapackage()
- PackageGenerator::generate in composer/
Generator/ PackageGenerator.php - Generate Drupal's metapackages whenever composer.lock is updated
File
- composer/
Generator/ PackageGenerator.php, line 87
Class
- PackageGenerator
- Generates metapackages.
Namespace
Drupal\Composer\GeneratorCode
protected function generateMetapackage(IOInterface $io, BuilderInterface $builder) {
// Load the existing composer.json file for drupal/core-recommended
$relative_path = $builder
->getPath() . '/composer.json';
$composer_json_path = $this->generatedProjectBaseDir . '/' . $relative_path;
$original_composer_json = file_exists($composer_json_path) ? file_get_contents($composer_json_path) : '';
// Get the composer.json file from the builder.
$composer_json_data = $builder
->getPackage();
$updated_composer_json = static::encode($composer_json_data);
// Exit early if nothing changed.
if (trim($original_composer_json, " \t\r\0\v") == trim($updated_composer_json, " \t\r\0\v")) {
return FALSE;
}
// Warn the user that a metapackage file has been updated..
$io
->write("Updated metapackage file <info>composer/Metapackage/{$relative_path}</info>.");
// Write the composer.json file back to disk
$fs = new Filesystem();
$fs
->ensureDirectoryExists(dirname($composer_json_path));
file_put_contents($composer_json_path, $updated_composer_json);
return TRUE;
}