function FixtureManipulator::modifyPackageConfig

Modifies a package's composer.json properties.

Parameters

string $package_name: The name of the package to modify.

string $version: The version to use for the modified package. Can be the same as the original version, or a different version.

array $config: The config to be added to the package's composer.json.

bool $is_dev_requirement: Whether the package is a development requirement.

See also

\Composer\Command\ConfigCommand

1 call to FixtureManipulator::modifyPackageConfig()
FixtureManipulator::setVersion in core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php
Sets a package version.

File

core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php, line 194

Class

FixtureManipulator
Manipulates a test fixture using Composer commands.

Namespace

Drupal\fixture_manipulator

Code

public function modifyPackageConfig(string $package_name, string $version, array $config, bool $is_dev_requirement = FALSE) : self {
    if (!$this->committingChanges) {
        $this->queueManipulation('modifyPackageConfig', func_get_args());
        return $this;
    }
    $package = [
        'name' => $package_name,
        'version' => $version,
    ] + $config;
    $this->addRepository($package);
    $this->runComposerCommand(array_filter([
        'require',
        "{$package_name}:{$version}",
        $is_dev_requirement ? '--dev' : NULL,
    ]));
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.