function FixtureManipulator::requirePackage

Requires a package.

Parameters

string $package: A package name.

string $version: A version constraint.

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

bool $allow_plugins: Whether to use the '--no-plugins' option.

1 call to FixtureManipulator::requirePackage()
FixtureManipulator::addPackage in core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php
Adds a package.

File

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

Class

FixtureManipulator
Manipulates a test fixture using Composer commands.

Namespace

Drupal\fixture_manipulator

Code

public function requirePackage(string $package, string $version, bool $is_dev_requirement = FALSE, bool $allow_plugins = FALSE) : self {
    if (!$this->committingChanges) {
        $this->queueManipulation('requirePackage', func_get_args());
        return $this;
    }
    $command_options = [
        'require',
        "{$package}:{$version}",
    ];
    if ($is_dev_requirement) {
        $command_options[] = '--dev';
    }
    // Unlike ComposerInspector::validate(), explicitly do NOT validate plugins.
    if (!$allow_plugins) {
        $command_options[] = '--no-plugins';
    }
    $this->runComposerCommand($command_options);
    return $this;
}

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