function ComposerInstallersTrait::setInstallerPaths

Sets the installer paths config.

Parameters

array $installer_paths: The installed paths.

string $directory: The fixture directory.

3 calls to ComposerInstallersTrait::setInstallerPaths()
ComposerInstallersTrait::installComposerInstallers in core/modules/package_manager/tests/src/Traits/ComposerInstallersTrait.php
Installs the composer/installers package.
GitExcluderTest::setUp in core/modules/package_manager/tests/src/Kernel/PathExcluder/GitExcluderTest.php
OverwriteExistingPackagesValidatorTest::testNewPackagesOverwriteExisting in core/modules/package_manager/tests/src/Kernel/OverwriteExistingPackagesValidatorTest.php
Tests that new installed packages overwrite existing directories.

File

core/modules/package_manager/tests/src/Traits/ComposerInstallersTrait.php, line 62

Class

ComposerInstallersTrait
A utility for kernel tests that need to use 'composer/installers'.

Namespace

Drupal\Tests\package_manager\Traits

Code

private function setInstallerPaths(array $installer_paths, string $directory) : void {
    // Respect any existing installer paths.
    $extra = $this->container
        ->get(ComposerInspector::class)
        ->getConfig('extra', $directory . '/composer.json');
    $existing_installer_paths = json_decode($extra, TRUE, flags: JSON_THROW_ON_ERROR)['installer-paths'] ?? [];
    (new FixtureManipulator())->addConfig([
        'extra.installer-paths' => $installer_paths + $existing_installer_paths,
    ])
        ->commitChanges($directory);
}

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