function PackageManagerBypassServiceProvider::alter

Overrides ServiceProviderBase::alter

File

core/modules/package_manager/tests/modules/package_manager_bypass/src/PackageManagerBypassServiceProvider.php, line 25

Class

PackageManagerBypassServiceProvider
Defines services to bypass Package Manager's core functionality.

Namespace

Drupal\package_manager_bypass

Code

public function alter(ContainerBuilder $container) : void {
    parent::alter($container);
    // By default, \Drupal\package_manager_bypass\NoOpStager is applied, except
    // when a test opts out by setting this setting to FALSE.
    // @see \Drupal\package_manager_bypass\NoOpStager::setLockFileShouldChange()
    if (Settings::get('package_manager_bypass_composer_stager', TRUE)) {
        $container->register(NoOpStager::class)
            ->setClass(NoOpStager::class)
            ->setPublic(FALSE)
            ->setAutowired(TRUE)
            ->setDecoratedService(StagerInterface::class);
    }
    $container->getDefinition(PathLocator::class)
        ->setClass(MockPathLocator::class)
        ->setAutowired(FALSE)
        ->setArguments([
        new Reference('state'),
        new Parameter('app.root'),
        new Reference('config.factory'),
        new Reference('file_system'),
    ]);
}

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